結果

問題 No.3282 Photos and Friends
ユーザー Lidelie
提出日時 2025-09-26 22:52:43
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 3,215 ms
コンパイル使用メモリ 294,988 KB
実行使用メモリ 13,692 KB
最終ジャッジ日時 2025-09-26 22:52:55
合計ジャッジ時間 11,067 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ll n,p,q; cin >> n >> p >> q;
    vector<tuple<ll,ll,ll,ll>> t;
    for(ll i = 0;i<n;i++){
        ll x,a,b; cin >> x >> a >> b;
        t.emplace_back(b,a,x,i);
    }
    vector<pair<ll,ll>> ans(n);
    ranges::sort(t);
    for(auto tup : t){
        auto[b,a,x,i] = tup;
        ll used = min({x,a,p});
        p -= used;
        x -= used;
        ans[i].first = used;
        ll t2;
        if(0<x){
            used = min({x,b,q});
            q -= used;
            x -= used;
            ans[i].second = used;
        }
        if(0<x){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    for(ll i = 0;i<n;i++)cout << ans[i].first << ' ' << ans[i].second << '\n'; 
}
0