답안 #923421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923421 2024-02-07T08:06:19 Z ting39 Snowball (JOI21_ho_t2) C++17
100 / 100
386 ms 12372 KB
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
signed main(){
	int n,q;
	cin>>n>>q;
	vector<int> dif(n-1),ans(n);
	int pre;
	cin>>pre;
	for(int i=1;i<n;i++){
		cin>>dif[i-1];
		int tmp=pre;
		pre=dif[i-1];
		dif[i-1]-=tmp;
	}
	vector<int> vv(n-1);
	for(int i=0;i<n-1;i++) vv[i]=i;
	sort(vv.begin(),vv.end(),[&](int i,int j){
		return dif[i]<dif[j];
	});
	int pos=0,mn=0,mx=0,now=0;
	while(q--){
		int x;
		cin>>x;
		while(pos<n-1&&dif[vv[pos]]<=max(mx,now+x)-min(mn,now+x)){//cout<<ans[vv[pos]]<<' '<<ans[vv[pos]+1]<<endl;
			ans[vv[pos]]+=mx;
			ans[vv[pos]+1]-=mn;
			if(x>0) ans[vv[pos]]+=dif[vv[pos]]-mx+mn;
			else ans[vv[pos]+1]+=dif[vv[pos]]-mx+mn;//cout<<ans[vv[pos]]<<' '<<ans[vv[pos]+1]<<endl;
			pos++;
		}
		now+=x;
		mx=max(mx,now);
		mn=min(mn,now);
	}
	while(pos<n-1){
		ans[vv[pos]]+=mx;
		ans[vv[pos]+1]-=mn;
		pos++;
	}
	ans[0]-=mn;
	ans[n-1]+=mx;
	for(int i:ans) cout<<i<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 516 KB Output is correct
7 Correct 4 ms 500 KB Output is correct
8 Correct 4 ms 524 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 0 ms 440 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 516 KB Output is correct
7 Correct 4 ms 500 KB Output is correct
8 Correct 4 ms 524 KB Output is correct
9 Correct 4 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 4 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 0 ms 440 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 62 ms 2384 KB Output is correct
21 Correct 57 ms 2308 KB Output is correct
22 Correct 54 ms 1948 KB Output is correct
23 Correct 52 ms 1876 KB Output is correct
24 Correct 75 ms 2640 KB Output is correct
25 Correct 353 ms 10576 KB Output is correct
26 Correct 351 ms 10196 KB Output is correct
27 Correct 355 ms 9936 KB Output is correct
28 Correct 352 ms 10148 KB Output is correct
29 Correct 352 ms 9748 KB Output is correct
30 Correct 337 ms 8928 KB Output is correct
31 Correct 327 ms 8796 KB Output is correct
32 Correct 317 ms 8532 KB Output is correct
33 Correct 36 ms 1372 KB Output is correct
34 Correct 358 ms 10736 KB Output is correct
35 Correct 351 ms 10212 KB Output is correct
36 Correct 355 ms 10340 KB Output is correct
37 Correct 351 ms 10068 KB Output is correct
38 Correct 349 ms 9936 KB Output is correct
39 Correct 344 ms 9988 KB Output is correct
40 Correct 346 ms 10168 KB Output is correct
41 Correct 75 ms 2900 KB Output is correct
42 Correct 340 ms 8888 KB Output is correct
43 Correct 367 ms 11856 KB Output is correct
44 Correct 72 ms 2900 KB Output is correct
45 Correct 351 ms 9936 KB Output is correct
46 Correct 384 ms 12372 KB Output is correct
47 Correct 386 ms 12112 KB Output is correct
48 Correct 376 ms 12284 KB Output is correct