Submission #944344

# Submission time Handle Problem Language Result Execution time Memory
944344 2024-03-12T15:24:16 Z dsyz Snowball (JOI21_ho_t2) C++17
100 / 100
835 ms 13832 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1000005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N,Q;
	cin>>N>>Q;
	ll X[N + 1];
	for(ll i = 0;i < N;i++){
		cin>>X[i];
	}
	X[N] = 1e18;
	ll cur = 0, maxi = 0, mini = 0;
	ll pmin[Q], pmax[Q], wind[Q];
	for(ll q = 0;q < Q;q++){
		cin>>wind[q];
		cur += wind[q];
		maxi = max(maxi,cur);
		mini = min(mini,cur);
		pmax[q] = maxi;
		pmin[q] = -1 * mini;
	}
	ll prev = X[0] + mini;
	for(ll i = 0;i < N;i++){
		ll Lb = max(prev,X[i] + mini);
		ll low = X[i];
		ll high = X[i + 1] + 1;
		while(high - low > 1){
			ll mid = (high + low) / 2;
			ll tmp1 = lower_bound(pmax,pmax + Q,mid - X[i]) - pmax;
			ll tmp2 = lower_bound(pmin,pmin + Q,X[i + 1] - mid + 1) - pmin;
			if(tmp1 < tmp2){
				low = mid;
			}else{
				high = mid;
			}
		}
		cout<<low - Lb<<'\n';
		prev = low;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 556 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 472 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 0 ms 456 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 5 ms 472 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 556 KB Output is correct
9 Correct 4 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 472 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 0 ms 456 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 5 ms 472 KB Output is correct
16 Correct 4 ms 348 KB Output is correct
17 Correct 3 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 20 ms 7044 KB Output is correct
21 Correct 19 ms 7004 KB Output is correct
22 Correct 23 ms 6876 KB Output is correct
23 Correct 26 ms 6736 KB Output is correct
24 Correct 99 ms 6968 KB Output is correct
25 Correct 833 ms 12040 KB Output is correct
26 Correct 794 ms 11800 KB Output is correct
27 Correct 759 ms 11724 KB Output is correct
28 Correct 738 ms 11872 KB Output is correct
29 Correct 705 ms 11508 KB Output is correct
30 Correct 461 ms 10528 KB Output is correct
31 Correct 64 ms 10044 KB Output is correct
32 Correct 45 ms 10024 KB Output is correct
33 Correct 64 ms 1572 KB Output is correct
34 Correct 718 ms 12428 KB Output is correct
35 Correct 727 ms 11640 KB Output is correct
36 Correct 835 ms 12176 KB Output is correct
37 Correct 798 ms 11732 KB Output is correct
38 Correct 758 ms 11556 KB Output is correct
39 Correct 763 ms 11824 KB Output is correct
40 Correct 225 ms 11616 KB Output is correct
41 Correct 21 ms 7812 KB Output is correct
42 Correct 157 ms 10032 KB Output is correct
43 Correct 191 ms 13468 KB Output is correct
44 Correct 24 ms 7684 KB Output is correct
45 Correct 315 ms 11680 KB Output is correct
46 Correct 214 ms 13524 KB Output is correct
47 Correct 197 ms 13648 KB Output is correct
48 Correct 200 ms 13832 KB Output is correct