답안 #493787

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493787 2021-12-13T01:53:17 Z nathanlee726 Snowball (JOI21_ho_t2) C++14
100 / 100
345 ms 18620 KB
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
#define int ll
#define pii pair<int,int>
#define X first
#define Y second
#define F(n) Fi(i,n) 
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define abs(x) ((x)>0?(x):-(x))
#define pb push_back

pii rg[200010];
int a[200010],b[200010],mr[200010],ml[200010],n,q;
vector<int> v;

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>q;
	F(n)cin>>a[i];
	F(q)cin>>b[i];
	mr[0]=0,ml[0]=0;
	int no=0;
	F(q){
		no+=b[i];
		mr[i+1]=max(mr[i],no);
		ml[i+1]=max(ml[i],-no);
	}
	F(q+1){
		v.pb(ml[i]+mr[i]);
	}
	rg[0].X=ml[q];
	rg[n-1].Y=mr[q];
	F(n-1){
		if(v[q]<=a[i+1]-a[i]){
			rg[i].Y=mr[q];
			rg[i+1].X=ml[q];
			continue;
		}
		int d=upper_bound(all(v),a[i+1]-a[i])-v.begin()-1;
		if(b[d]>0){
			rg[i].Y=a[i+1]-a[i]-ml[d+1];
			rg[i+1].X=ml[d+1];
		}
		else{
			rg[i].Y=mr[d+1];
			rg[i+1].X=a[i+1]-a[i]-mr[d+1];
		}
	} 
	//F(n)cout<<rg[i].X<<" "<<rg[i].Y<<endl;

	F(n){
		cout<<rg[i].X+rg[i].Y<<endl;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 4 ms 464 KB Output is correct
5 Correct 3 ms 464 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 3 ms 500 KB Output is correct
8 Correct 3 ms 464 KB Output is correct
9 Correct 3 ms 464 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 3 ms 464 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 3 ms 464 KB Output is correct
16 Correct 4 ms 464 KB Output is correct
17 Correct 3 ms 500 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 3 ms 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 4 ms 464 KB Output is correct
5 Correct 3 ms 464 KB Output is correct
6 Correct 4 ms 464 KB Output is correct
7 Correct 3 ms 500 KB Output is correct
8 Correct 3 ms 464 KB Output is correct
9 Correct 3 ms 464 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 3 ms 464 KB Output is correct
12 Correct 0 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 3 ms 464 KB Output is correct
16 Correct 4 ms 464 KB Output is correct
17 Correct 3 ms 500 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 3 ms 464 KB Output is correct
20 Correct 28 ms 9276 KB Output is correct
21 Correct 38 ms 9028 KB Output is correct
22 Correct 26 ms 8900 KB Output is correct
23 Correct 26 ms 8804 KB Output is correct
24 Correct 52 ms 8892 KB Output is correct
25 Correct 317 ms 16684 KB Output is correct
26 Correct 313 ms 16652 KB Output is correct
27 Correct 314 ms 16232 KB Output is correct
28 Correct 312 ms 16492 KB Output is correct
29 Correct 326 ms 15956 KB Output is correct
30 Correct 306 ms 15276 KB Output is correct
31 Correct 278 ms 14768 KB Output is correct
32 Correct 277 ms 14908 KB Output is correct
33 Correct 34 ms 2092 KB Output is correct
34 Correct 307 ms 17080 KB Output is correct
35 Correct 331 ms 16392 KB Output is correct
36 Correct 309 ms 16720 KB Output is correct
37 Correct 345 ms 16372 KB Output is correct
38 Correct 314 ms 16288 KB Output is correct
39 Correct 320 ms 16516 KB Output is correct
40 Correct 276 ms 16456 KB Output is correct
41 Correct 30 ms 9932 KB Output is correct
42 Correct 270 ms 15088 KB Output is correct
43 Correct 284 ms 18228 KB Output is correct
44 Correct 31 ms 9804 KB Output is correct
45 Correct 279 ms 16516 KB Output is correct
46 Correct 306 ms 18380 KB Output is correct
47 Correct 296 ms 18508 KB Output is correct
48 Correct 292 ms 18620 KB Output is correct