# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
936847 |
2024-03-02T20:39:19 Z |
jcelin |
Snowball (JOI21_ho_t2) |
C++14 |
|
132 ms |
25652 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 7;
const ll INF = 1e18 + 7;
const int logo = 20;
const int off = 1 << logo;
ll L[MAXN], R[MAXN], arr[MAXN];
ll neg[MAXN], poz[MAXN], w[MAXN];
void solve(){
int n, q;
cin >> n >> q;
for(int i=1; i<=n; i++) cin >> arr[i];
ll cd = 0;
for(int i=1; i<=q; i++){
cin >> w[i];
cd += w[i];
neg[i] = min(neg[i - 1], cd);
poz[i] = max(poz[i - 1], cd);
}
L[1] = arr[1] + neg[q];
R[n] = arr[n] + poz[q];
for(int i=1; i<n; i++){
int lo = 1, hi = q, ret = -1;
ll delt = arr[i + 1] - arr[i];
while(lo <= hi){
int mid = (lo + hi) / 2;
if(poz[mid] + abs<ll>(neg[mid]) >= delt) ret = mid, hi = mid - 1;
else lo = mid + 1;
}
if(ret == -1){
R[i] = arr[i] + poz[q];
L[i + 1] = arr[i + 1] + neg[q];
}else{
R[i] = arr[i] + poz[ret - 1];
L[i + 1] = arr[i + 1] + neg[ret - 1];
if(w[ret] < 0) L[i + 1] = R[i];
else R[i] = L[i + 1];
}
}
for(int i=1; i<=n; i++) cout << R[i] - L[i] << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int tt = 1;
//cin >> tt;
while(tt--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6684 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6820 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6716 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6748 KB |
Output is correct |
16 |
Correct |
2 ms |
6748 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
2 ms |
6684 KB |
Output is correct |
3 |
Correct |
2 ms |
6492 KB |
Output is correct |
4 |
Correct |
2 ms |
6820 KB |
Output is correct |
5 |
Correct |
2 ms |
6492 KB |
Output is correct |
6 |
Correct |
3 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6492 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6716 KB |
Output is correct |
10 |
Correct |
2 ms |
6492 KB |
Output is correct |
11 |
Correct |
1 ms |
6492 KB |
Output is correct |
12 |
Correct |
1 ms |
6492 KB |
Output is correct |
13 |
Correct |
1 ms |
6492 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6748 KB |
Output is correct |
16 |
Correct |
2 ms |
6748 KB |
Output is correct |
17 |
Correct |
2 ms |
6748 KB |
Output is correct |
18 |
Correct |
1 ms |
6492 KB |
Output is correct |
19 |
Correct |
1 ms |
6620 KB |
Output is correct |
20 |
Correct |
23 ms |
16356 KB |
Output is correct |
21 |
Correct |
23 ms |
16220 KB |
Output is correct |
22 |
Correct |
25 ms |
15992 KB |
Output is correct |
23 |
Correct |
20 ms |
15976 KB |
Output is correct |
24 |
Correct |
26 ms |
18268 KB |
Output is correct |
25 |
Correct |
111 ms |
23728 KB |
Output is correct |
26 |
Correct |
109 ms |
23748 KB |
Output is correct |
27 |
Correct |
105 ms |
23352 KB |
Output is correct |
28 |
Correct |
132 ms |
23520 KB |
Output is correct |
29 |
Correct |
109 ms |
22956 KB |
Output is correct |
30 |
Correct |
113 ms |
22344 KB |
Output is correct |
31 |
Correct |
60 ms |
21944 KB |
Output is correct |
32 |
Correct |
46 ms |
21952 KB |
Output is correct |
33 |
Correct |
10 ms |
9560 KB |
Output is correct |
34 |
Correct |
117 ms |
24104 KB |
Output is correct |
35 |
Correct |
109 ms |
23612 KB |
Output is correct |
36 |
Correct |
105 ms |
23868 KB |
Output is correct |
37 |
Correct |
110 ms |
23496 KB |
Output is correct |
38 |
Correct |
110 ms |
23236 KB |
Output is correct |
39 |
Correct |
104 ms |
23544 KB |
Output is correct |
40 |
Correct |
72 ms |
23584 KB |
Output is correct |
41 |
Correct |
24 ms |
16976 KB |
Output is correct |
42 |
Correct |
56 ms |
22032 KB |
Output is correct |
43 |
Correct |
74 ms |
25388 KB |
Output is correct |
44 |
Correct |
27 ms |
16988 KB |
Output is correct |
45 |
Correct |
65 ms |
23376 KB |
Output is correct |
46 |
Correct |
80 ms |
25440 KB |
Output is correct |
47 |
Correct |
67 ms |
21344 KB |
Output is correct |
48 |
Correct |
66 ms |
25652 KB |
Output is correct |