# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
412981 |
2021-05-27T22:26:38 Z |
Ozy |
Snowball (JOI21_ho_t2) |
C++17 |
|
2500 ms |
2368 KB |
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl
#define MAX 200000
#define pos first
#define l second.first
#define r second.second
pair<lli, pair<lli,lli> > arr[MAX+2];
lli n,q,a;
lli res[MAX+1];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> q;
a = 1ll<<62;
arr[0].l = -a;
arr[0].r = -a;
arr[n+1].l = a;
arr[n+1].r = a;
rep(i,1,n) {
cin >> a;
arr[i].l = a;
arr[i].r = a;
arr[i].pos = a;
}
rep(x,1,q) {
cin >> a;
rep(i,1,n) {
if (a < 0) {
if ((arr[i-1].r < arr[i].l) && arr[i].pos+a < arr[i].l) {
res[i] += arr[i].l - max((arr[i-1].r), arr[i].pos+a);
}
arr[i].pos += a;
arr[i].l = min(arr[i].l, arr[i].pos);
}
else if (a > 0) {
if ((arr[i+1].l > arr[i].r) && arr[i].pos+a > arr[i].r) {
res[i] += min(arr[i+1].l, arr[i].pos+a) - arr[i].r;
}
arr[i].pos += a;
arr[i].r = max(arr[i].pos, arr[i].r);
}
}
}
rep(i,1,n) cout << res[i] << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
360 KB |
Output is correct |
4 |
Correct |
14 ms |
440 KB |
Output is correct |
5 |
Correct |
14 ms |
432 KB |
Output is correct |
6 |
Correct |
14 ms |
332 KB |
Output is correct |
7 |
Correct |
14 ms |
332 KB |
Output is correct |
8 |
Correct |
15 ms |
332 KB |
Output is correct |
9 |
Correct |
14 ms |
340 KB |
Output is correct |
10 |
Correct |
12 ms |
432 KB |
Output is correct |
11 |
Correct |
8 ms |
424 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
14 ms |
440 KB |
Output is correct |
16 |
Correct |
14 ms |
440 KB |
Output is correct |
17 |
Correct |
12 ms |
460 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
7 ms |
412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
360 KB |
Output is correct |
4 |
Correct |
14 ms |
440 KB |
Output is correct |
5 |
Correct |
14 ms |
432 KB |
Output is correct |
6 |
Correct |
14 ms |
332 KB |
Output is correct |
7 |
Correct |
14 ms |
332 KB |
Output is correct |
8 |
Correct |
15 ms |
332 KB |
Output is correct |
9 |
Correct |
14 ms |
340 KB |
Output is correct |
10 |
Correct |
12 ms |
432 KB |
Output is correct |
11 |
Correct |
8 ms |
424 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
14 ms |
440 KB |
Output is correct |
16 |
Correct |
14 ms |
440 KB |
Output is correct |
17 |
Correct |
12 ms |
460 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
7 ms |
412 KB |
Output is correct |
20 |
Correct |
33 ms |
2368 KB |
Output is correct |
21 |
Correct |
40 ms |
2232 KB |
Output is correct |
22 |
Correct |
113 ms |
2088 KB |
Output is correct |
23 |
Correct |
1185 ms |
1952 KB |
Output is correct |
24 |
Execution timed out |
2573 ms |
1572 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |