結果
問題 |
No.3282 Photos and Friends
|
ユーザー |
|
提出日時 | 2025-09-26 21:50:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 972 bytes |
コンパイル時間 | 1,845 ms |
コンパイル使用メモリ | 198,484 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2025-09-26 21:50:46 |
合計ジャッジ時間 | 8,638 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 WA * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); long long N,P,Q; cin >> N >> P >> Q; long long p = 0,q = 0,move = 0; vector<long long> A(N),X(N),M(N); for(int i=0; i<N; i++){ long long x,a,b; cin >> x >> a >> b; A.at(i) = a,X.at(i) = x; if(a+b < x){cout << "No\n"; return 0;} if(a >= x) M.at(i) = min(x,b),p += a; else{ p += a,q += x-a; b -= x-a,M.at(i) = min({a,b}); } } for(auto &m : M) move += m; if((P >= p && Q >= q) || (p-P <= move && q+max(0LL,p-P) <= Q)){ move = max(0LL,p-P); cout << "Yes\n"; for(int i=0; i<N; i++){ long long a = A.at(i),x = X.at(i),m = min(move,M.at(i)); a = min(a,x),move -= m; long long b = x-a; a -= m,b += m; cout << a << " " << b << "\n"; } } else cout << "No\n"; }