답안 #734292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734292 2023-05-02T08:37:02 Z josanneo22 Rainy Markets (CCO22_day1problem2) C++17
0 / 25
243 ms 55436 KB
#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]){//just use i
			dp[i]+=p[i];//use on i
			p[i]=0;
			ans[i][0]+=p[i];//fully stay on i
		}
		else{
			dp[i]+=left;//use up rest
			ans[i][0]+=left;//those go left
			p[i]-=left;//remove all go left
			left=b[i+1];//now i have i+1
			if(left>=p[i]){//if currently enough
				dp[i+1]+=p[i];//go right(i+1)
				ans[i][2]+=p[i];//those go right 
			}
			else{
				ok=0;//insufficient to use all  
			}
		}
	}
	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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 205 ms 55292 KB Output is correct
5 Correct 243 ms 55292 KB Output is correct
6 Correct 214 ms 55372 KB Output is correct
7 Correct 240 ms 55436 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Incorrect 3 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 205 ms 55292 KB Output is correct
5 Correct 243 ms 55292 KB Output is correct
6 Correct 214 ms 55372 KB Output is correct
7 Correct 240 ms 55436 KB Output is correct
8 Correct 4 ms 596 KB Output is correct
9 Incorrect 3 ms 596 KB Output isn't correct
10 Halted 0 ms 0 KB -