#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] = min(p[i], l[i+1]);
else 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 |
348 KB |
Output is correct |
4 |
Correct |
9 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
520 KB |
Output is correct |
6 |
Incorrect |
5 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
9 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
520 KB |
Output is correct |
6 |
Incorrect |
5 ms |
348 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |