結果

問題 No.3282 Photos and Friends
ユーザー t98slider
提出日時 2025-09-26 21:43:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,183 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 208,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2025-09-26 21:43:46
合計ジャッジ時間 8,830 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 46 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, p, q;
    cin >> n >> p >> q;
    vector<tuple<ll,ll,ll,int>> a(n);
    for(int i = 0; i < n; i++){
        auto &&[x, y, z, idx] = a[i];
        idx = i;
        cin >> x >> y >> z;
    }
    sort(a.begin(), a.end(), [&](tuple<ll,ll,ll,int> lhs, tuple<ll,ll,ll,int> rhs){
        return (get<1>(lhs) + get<2>(lhs)) * get<0>(rhs) < 
                (get<1>(rhs) + get<2>(rhs)) * get<0>(lhs);
    });

    vector<pair<ll,ll>> b(n);
    for(auto [x, y, z, idx] : a){
        if(p > q){
            ll d = min({x, y, p});
            p -= d, x -= d;
            b[idx].first = d;
            d = min({x, z, q});
            q -= d, x -= d;
            b[idx].second = d;
        }else{
            ll d = min({x, z, q});
            q -= d, x -= d;
            b[idx].second = d;
            d = min({x, y, p});
            p -= d, x -= d;
            b[idx].first = d;
        }
        if(x != 0){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for(auto [x, y] : b) cout << x << ' ' << y << '\n';
}
0