#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2010;
int r[N],l[N];
int p[N];
int32_t main(){
int n, q;
cin >> n;
cin >> q;
for(int i = 1;i <= n;i++){
cin >> p[i];
l[i] = r[i] = p[i];
}
r[0] = -(1LL << 62);
l[n+1] = (1LL << 62);
while(q--){
int x;
cin >> x;
for(int i = 1;i <= n;i++){
p[i] += x;
if(x > 0) r[i] = max(r[i], min(p[i], l[i+1]));
else l[i] = min(l[i], max(p[i], r[i-1]));
}
}
for(int i = 1;i <= n;i++) cout << r[i] - l[i] << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
452 KB |
Output is correct |
4 |
Correct |
6 ms |
528 KB |
Output is correct |
5 |
Correct |
6 ms |
520 KB |
Output is correct |
6 |
Correct |
11 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
516 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
8 ms |
348 KB |
Output is correct |
16 |
Correct |
11 ms |
348 KB |
Output is correct |
17 |
Correct |
6 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
420 KB |
Output is correct |
19 |
Correct |
5 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
452 KB |
Output is correct |
4 |
Correct |
6 ms |
528 KB |
Output is correct |
5 |
Correct |
6 ms |
520 KB |
Output is correct |
6 |
Correct |
11 ms |
512 KB |
Output is correct |
7 |
Correct |
6 ms |
516 KB |
Output is correct |
8 |
Correct |
6 ms |
348 KB |
Output is correct |
9 |
Correct |
6 ms |
348 KB |
Output is correct |
10 |
Correct |
6 ms |
348 KB |
Output is correct |
11 |
Correct |
6 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
8 ms |
348 KB |
Output is correct |
16 |
Correct |
11 ms |
348 KB |
Output is correct |
17 |
Correct |
6 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
420 KB |
Output is correct |
19 |
Correct |
5 ms |
348 KB |
Output is correct |
20 |
Correct |
84 ms |
2640 KB |
Output is correct |
21 |
Correct |
82 ms |
2132 KB |
Output is correct |
22 |
Correct |
87 ms |
2084 KB |
Output is correct |
23 |
Correct |
522 ms |
1976 KB |
Output is correct |
24 |
Runtime error |
2 ms |
600 KB |
Execution killed with signal 11 |
25 |
Halted |
0 ms |
0 KB |
- |