Submission #493789

# Submission time Handle Problem Language Result Execution time Memory
493789 2021-12-13T01:54:09 Z PixelCat Snowball (JOI21_ho_t2) C++14
100 / 100
107 ms 9564 KB
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define INF (1000000000000000ll);
#define int ll
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int mx[200020];
int mn[200020];
int x[200020];
int w[200020];

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// nachoneko sama & miku sama bless me >/////<
	int n,q; cin>>n>>q;
	For(i,1,n) cin>>x[i];
	int now=0;
	For(i,1,q){
		int t; cin>>t;
		now+=t;
		mx[i]=max(mx[i-1],now);
		mn[i]=min(mn[i-1],now);
	}
	w[1]-=mn[q];
	w[n]+=mx[q];
	For(i,1,n-1){
		int d=x[i+1]-x[i];
		if(d>mx[q]-mn[q]){
			w[i]+=mx[q];
			w[i+1]-=mn[q];
			continue;
		}
		int hi=q,lo=0;
		while(hi-lo>1){
			int mi=(hi+lo)/2;
			if(mx[mi]-mn[mi]>=d) hi=mi;
			else lo=mi;
		}
		w[i]+=mx[lo];
		w[i+1]-=mn[lo];
		d-=mx[lo]-mn[lo];
		if(mx[hi]>mx[lo]) w[i]+=d;
		else if(mn[hi]<mn[lo]) w[i+1]+=d;
		else assert(false);
	}
	For(i,1,n) cout<<w[i]<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 27 ms 4492 KB Output is correct
21 Correct 28 ms 4588 KB Output is correct
22 Correct 28 ms 4548 KB Output is correct
23 Correct 22 ms 4612 KB Output is correct
24 Correct 33 ms 5000 KB Output is correct
25 Correct 105 ms 9284 KB Output is correct
26 Correct 104 ms 9200 KB Output is correct
27 Correct 100 ms 9028 KB Output is correct
28 Correct 106 ms 9088 KB Output is correct
29 Correct 99 ms 8820 KB Output is correct
30 Correct 96 ms 8456 KB Output is correct
31 Correct 75 ms 8004 KB Output is correct
32 Correct 75 ms 8012 KB Output is correct
33 Correct 10 ms 1484 KB Output is correct
34 Correct 107 ms 9212 KB Output is correct
35 Correct 98 ms 9104 KB Output is correct
36 Correct 100 ms 9284 KB Output is correct
37 Correct 107 ms 9136 KB Output is correct
38 Correct 97 ms 9028 KB Output is correct
39 Correct 94 ms 9028 KB Output is correct
40 Correct 84 ms 9024 KB Output is correct
41 Correct 30 ms 4592 KB Output is correct
42 Correct 56 ms 8040 KB Output is correct
43 Correct 87 ms 9264 KB Output is correct
44 Correct 30 ms 4580 KB Output is correct
45 Correct 63 ms 9028 KB Output is correct
46 Correct 88 ms 9396 KB Output is correct
47 Correct 95 ms 9564 KB Output is correct
48 Correct 94 ms 9356 KB Output is correct