# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
568684 | 2022-05-26T04:56:01 Z | dantoh000 | Snowball (JOI21_ho_t2) | C++14 | 2 ms | 468 KB |
#include <bits/stdc++.h> #define int long long using namespace std; int n,q; int p[200005]; int D[200005]; int l[200005]; int r[200005]; int pos[200005]; int ans[200005]; main(){ scanf("%lld%lld",&n,&q); for (int i = 1; i <= n; i++){ scanf("%lld",&p[i]); } int cur = 0; l[0] = r[0] = D[0] = 0; for (int i = 1, x; i <= q; i++){ scanf("%lld",&x); cur += x; l[i] = min(l[i-1], cur); r[i] = max(r[i-1], cur); D[i] = r[i]-l[i]; pos[i] = cur; } ans[1] += -l[q]; ans[n] += r[q]; for (int i = 1; i <= n; i++){ int d = p[i+1]-p[i]; int id = lower_bound(D, D+q, d) - D; int L = -l[id]; int R = r[id]; if (pos[id] == l[id]) L = min(L, max(0ll,d - R)); else if (pos[id] == r[id]) R = min(R, max(0ll,d - L)); ///printf("position %d moves %d left, position %d moves %d right\n",i+1,L,i,R); ans[i] += R; ans[i+1] += L; } for (int i = 1; i <= n; i++){ printf("%lld\n",ans[i]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 468 KB | Output is correct |
7 | Correct | 2 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 468 KB | Output is correct |
9 | Correct | 1 ms | 444 KB | Output is correct |
10 | Incorrect | 2 ms | 452 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 2 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 468 KB | Output is correct |
7 | Correct | 2 ms | 468 KB | Output is correct |
8 | Correct | 1 ms | 468 KB | Output is correct |
9 | Correct | 1 ms | 444 KB | Output is correct |
10 | Incorrect | 2 ms | 452 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |