#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n; cin>>n;
vector<int> b(n),p(n-1),u(n-1);
for(auto&x:b) cin>>x;
for(auto&x:p) cin>>x;
for(auto&x:u) cin>>x;
int ans[n][3]; memset(ans,0,sizeof(ans));
int dp[n+1];memset(dp,0,sizeof(dp));
int ok=1;
for(int i=0;i<n-1;i++){
int left=b[i]-dp[i];
if(left>=p[i]){
dp[i]+=p[i];
p[i]=0;
ans[i][0]=p[i];
}
else{
dp[i]+=left;
ans[i][0]=left;
p[i]-=left;
left=b[i+1];
if(left>=p[i]){
dp[i+1]+=p[i];
ans[i][2]=p[i];
p[i]=0;
}
else{
ok=0;
}
}
}
if(ok){
cout<<"YES\n";
cout<<0<<'\n';
for(int i=0;i<n-1;i++){
cout<<ans[i][0]<<' '<<ans[i][1]<<' '<<ans[i][2]<<'\n';
}
}
else{
cout<<"NO\n";
}
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int tt = 1;
while (tt--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
218 ms |
70656 KB |
Output is correct |
5 |
Correct |
275 ms |
76536 KB |
Output is correct |
6 |
Correct |
217 ms |
70844 KB |
Output is correct |
7 |
Correct |
262 ms |
76664 KB |
Output is correct |
8 |
Correct |
2 ms |
588 KB |
Output is correct |
9 |
Incorrect |
3 ms |
624 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
324 KB |
Output is correct |
4 |
Correct |
218 ms |
70656 KB |
Output is correct |
5 |
Correct |
275 ms |
76536 KB |
Output is correct |
6 |
Correct |
217 ms |
70844 KB |
Output is correct |
7 |
Correct |
262 ms |
76664 KB |
Output is correct |
8 |
Correct |
2 ms |
588 KB |
Output is correct |
9 |
Incorrect |
3 ms |
624 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |