結果
| 問題 |
No.3282 Photos and Friends
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-26 22:49:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,745 bytes |
| コンパイル時間 | 4,436 ms |
| コンパイル使用メモリ | 257,672 KB |
| 実行使用メモリ | 22,768 KB |
| 最終ジャッジ日時 | 2025-09-26 22:50:05 |
| 合計ジャッジ時間 | 12,172 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 39 WA * 11 |
ソースコード
#include<iostream>
#include<atcoder/all>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
#include <numeric>
#include <random>
#include<map>
#include<queue>
#include<deque>
#include <bitset>
#include<stack>
#include<set>
using namespace std;
using namespace atcoder;
#define int long long
using mint=modint998244353;
double pi=3.141592653589793128;
//cout << fixed << setprecision(10);
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for (int i=0;i<(n);++i)
#define prep(i,n) for (int i=1;i<=(n);++i)
#define ep(i,j,n) for (int i=j+1;i<=(n);++i)
long long INF = 900000000000000;
int mod=998244353;
signed main(){
int n,P,Q;cin>>n>>P>>Q;
int x[n],a[n],b[n];
rep(i,n){cin>>x[i]>>a[i]>>b[i];if(a[i]+b[i]<x[i]){cout<<"No";return 0;}}
pair<int,int> ans[n];
rep(i,n)ans[i]={0,0};
vector<pair<int,int>> p;
rep(i,n)p.push_back({x[i]-b[i],i});
sort(all(p));
rep(i,n){
if(p[i].first<=0)continue;
P-=p[i].first;
ans[p[i].second].first+=p[i].first;
a[p[i].second]-=p[i].first;
}
if(P<0){cout<<"No";return 0;}
//cout<<P<<endl;
vector<pair<int,int>> pp;
rep(i,n)pp.push_back({a[i],i});
sort(all(pp));
rep(i,n){
int z=ans[pp[i].second].first;
int y=ans[pp[i].second].second;
int hh=min(b[pp[i].second],Q);
hh=min(hh,x[pp[i].second]-z-y);
y+=hh;
Q-=hh;
int u=min(a[pp[i].second],P);
int zero=0;
int h=max(zero,x[pp[i].second]-z-y);
u=min(u,h);
z+=u;
P-=u;
// cout<<pp[i].second<<" "<<z<<" "<<y<<endl;
if(y+z<x[pp[i].second]){
cout<<"No";return 0;
}
ans[pp[i].second]={z,y};
}
cout<<"Yes"<<endl;
rep(i,n){
cout<<ans[i].first<<" "<<ans[i].second<<endl;
}
}