結果

問題 No.3282 Photos and Friends
ユーザー forest3
提出日時 2025-10-04 02:04:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 576 ms / 2,000 ms
コード長 752 bytes
コンパイル時間 1,867 ms
コンパイル使用メモリ 163,860 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-04 02:05:04
合計ジャッジ時間 12,993 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, a, b) for (int i = a; i < b; i++)
using ll = long long;

int main() {
	ll n, p, q;
	cin >> n >> p >> q;;
	vector<int> x(n), a(n), b(n);
	rep(i, 0, n) cin >> x[i] >> a[i] >> b[i];
	auto  er = []() {
		cout << "No" << endl;
		exit(0);
	};
	ll sx = 0, sl = 0, sr = 0;
	rep(i, 0, n) {
		if(x[i] > a[i] + b[i]) er();
		sx += x[i];
		int l = max(0, x[i] - b[i]);
		int r = min(a[i], x[i]);
		sl += l;
		sr += r;
	}
	if (sx > min(p, sr) + q) er();
	if(sl > p) er();
	cout << "Yes" << endl;
	ll d = p - sl;
	rep(i, 0, n) {
		ll l = max(0, x[i] - b[i]);
		ll r = min(a[i], x[i]);
		ll add = min(r - l, d);
		int aa = l + add;
		d -= add;
		int bb = x[i] - aa;
		cout << aa << " " << bb << endl;
	}
}
0