답안 #734293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
734293 2023-05-02T08:43:29 Z josanneo22 Rainy Markets (CCO22_day1problem2) C++17
5 / 25
483 ms 98568 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]; 
		int tmp=p[i];
		if(left>=p[i]){//just use i
			dp[i]+=p[i];//use on i
			ans[i][0]+=p[i];//fully stay on i
			p[i]=0;
		}
		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  
			}
		}
		p[i]=tmp;
	}
	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 1 ms 340 KB Output is correct
2 Correct 1 ms 260 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 207 ms 55136 KB Output is correct
5 Correct 235 ms 55116 KB Output is correct
6 Correct 204 ms 55036 KB Output is correct
7 Correct 237 ms 55044 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 332 ms 67512 KB Output is correct
11 Correct 344 ms 70776 KB Output is correct
12 Correct 457 ms 96496 KB Output is correct
13 Correct 454 ms 91632 KB Output is correct
14 Correct 214 ms 70012 KB Output is correct
15 Correct 438 ms 98380 KB Output is correct
16 Correct 449 ms 98432 KB Output is correct
17 Correct 450 ms 98568 KB Output is correct
18 Correct 470 ms 98472 KB Output is correct
19 Correct 444 ms 98424 KB Output is correct
20 Correct 450 ms 98372 KB Output is correct
21 Correct 453 ms 98284 KB Output is correct
22 Correct 448 ms 95992 KB Output is correct
23 Correct 451 ms 98484 KB Output is correct
24 Correct 475 ms 97528 KB Output is correct
25 Correct 265 ms 76668 KB Output is correct
26 Correct 260 ms 76648 KB Output is correct
27 Correct 467 ms 98336 KB Output is correct
28 Correct 458 ms 96160 KB Output is correct
29 Correct 469 ms 98020 KB Output is correct
30 Correct 471 ms 97540 KB Output is correct
31 Correct 483 ms 96264 KB Output is correct
32 Correct 474 ms 97264 KB Output is correct
33 Correct 272 ms 76236 KB Output is correct
34 Correct 265 ms 76192 KB Output is correct
35 Correct 277 ms 76260 KB Output is correct
# 결과 실행 시간 메모리 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 340 KB Output is correct
2 Correct 1 ms 260 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 207 ms 55136 KB Output is correct
5 Correct 235 ms 55116 KB Output is correct
6 Correct 204 ms 55036 KB Output is correct
7 Correct 237 ms 55044 KB Output is correct
8 Correct 2 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 332 ms 67512 KB Output is correct
11 Correct 344 ms 70776 KB Output is correct
12 Correct 457 ms 96496 KB Output is correct
13 Correct 454 ms 91632 KB Output is correct
14 Correct 214 ms 70012 KB Output is correct
15 Correct 438 ms 98380 KB Output is correct
16 Correct 449 ms 98432 KB Output is correct
17 Correct 450 ms 98568 KB Output is correct
18 Correct 470 ms 98472 KB Output is correct
19 Correct 444 ms 98424 KB Output is correct
20 Correct 450 ms 98372 KB Output is correct
21 Correct 453 ms 98284 KB Output is correct
22 Correct 448 ms 95992 KB Output is correct
23 Correct 451 ms 98484 KB Output is correct
24 Correct 475 ms 97528 KB Output is correct
25 Correct 265 ms 76668 KB Output is correct
26 Correct 260 ms 76648 KB Output is correct
27 Correct 467 ms 98336 KB Output is correct
28 Correct 458 ms 96160 KB Output is correct
29 Correct 469 ms 98020 KB Output is correct
30 Correct 471 ms 97540 KB Output is correct
31 Correct 483 ms 96264 KB Output is correct
32 Correct 474 ms 97264 KB Output is correct
33 Correct 272 ms 76236 KB Output is correct
34 Correct 265 ms 76192 KB Output is correct
35 Correct 277 ms 76260 KB Output is correct
36 Incorrect 1 ms 212 KB Output isn't correct
37 Halted 0 ms 0 KB -