#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];
int dp[n+1];
for(int i=0;i<n;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;
p[i]-=left;
dp[i+1]+=p[i];
ans[i][2]=p[i];
}
}
int ok=1;
for(int i=0;i<n;i++){
if(dp[i]>b[i]) ok=0;
}
if(dp[n]) ok=0;
if(ok){
cout<<"YES\n";
for(int i=0;i<n;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();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |