This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n; cin >> n;
int p[n - 1], b[n], u[n - 1];
pair <int, pair <int, int> > ans[n - 1];
for (int i = 0; i < n; i++) cin >> b[i];
for (int i = 0; i < n - 1; i++) cin >> p[i];
for (int i = 0; i < n - 1; i++) cin >> u[i];
bool poss = true;
for (int i = n - 2; i >= 0; i--){
ans[i].se.se = min(b[i + 1], p[i]);
b[i + 1] -= ans[i].se.se;
p[i] -= ans[i].se.se;
ans[i].se.fi = 0;
ans[i].fi = min(b[i], p[i]);
b[i] -= ans[i].fi;
p[i] -= ans[i].fi;
if (p[i] > 0) poss = false;
}
if (poss){
cout << "YES\n0\n";
for (int i = 0; i < n - 1; i++){
cout << ans[i].fi << ' ' << ans[i].se.fi << ' ' << ans[i].se.se << '\n';
}
}
else cout << "NO\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |