# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
936759 |
2024-03-02T16:54:04 Z |
vjudge1 |
Snowball (JOI21_ho_t2) |
C++17 |
|
116 ms |
25100 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 |
2 ms |
6616 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6616 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
3 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6488 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6488 KB |
Output is correct |
11 |
Correct |
2 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 |
2 ms |
6488 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 |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6616 KB |
Output is correct |
2 |
Correct |
2 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6616 KB |
Output is correct |
4 |
Correct |
2 ms |
6492 KB |
Output is correct |
5 |
Correct |
3 ms |
6492 KB |
Output is correct |
6 |
Correct |
2 ms |
6492 KB |
Output is correct |
7 |
Correct |
2 ms |
6488 KB |
Output is correct |
8 |
Correct |
2 ms |
6492 KB |
Output is correct |
9 |
Correct |
2 ms |
6492 KB |
Output is correct |
10 |
Correct |
2 ms |
6488 KB |
Output is correct |
11 |
Correct |
2 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 |
2 ms |
6488 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 |
6492 KB |
Output is correct |
20 |
Correct |
21 ms |
16368 KB |
Output is correct |
21 |
Correct |
21 ms |
16256 KB |
Output is correct |
22 |
Correct |
18 ms |
16068 KB |
Output is correct |
23 |
Correct |
19 ms |
16216 KB |
Output is correct |
24 |
Correct |
31 ms |
18264 KB |
Output is correct |
25 |
Correct |
103 ms |
23636 KB |
Output is correct |
26 |
Correct |
107 ms |
23416 KB |
Output is correct |
27 |
Correct |
103 ms |
23128 KB |
Output is correct |
28 |
Correct |
104 ms |
23156 KB |
Output is correct |
29 |
Correct |
102 ms |
22868 KB |
Output is correct |
30 |
Correct |
108 ms |
22232 KB |
Output is correct |
31 |
Correct |
60 ms |
21540 KB |
Output is correct |
32 |
Correct |
47 ms |
22048 KB |
Output is correct |
33 |
Correct |
11 ms |
9564 KB |
Output is correct |
34 |
Correct |
106 ms |
23536 KB |
Output is correct |
35 |
Correct |
108 ms |
23068 KB |
Output is correct |
36 |
Correct |
113 ms |
23424 KB |
Output is correct |
37 |
Correct |
105 ms |
23120 KB |
Output is correct |
38 |
Correct |
104 ms |
23124 KB |
Output is correct |
39 |
Correct |
116 ms |
23152 KB |
Output is correct |
40 |
Correct |
79 ms |
23124 KB |
Output is correct |
41 |
Correct |
23 ms |
17256 KB |
Output is correct |
42 |
Correct |
44 ms |
21724 KB |
Output is correct |
43 |
Correct |
64 ms |
24656 KB |
Output is correct |
44 |
Correct |
22 ms |
16980 KB |
Output is correct |
45 |
Correct |
63 ms |
23268 KB |
Output is correct |
46 |
Correct |
65 ms |
24756 KB |
Output is correct |
47 |
Correct |
74 ms |
25100 KB |
Output is correct |
48 |
Correct |
70 ms |
24912 KB |
Output is correct |