# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
568685 | dantoh000 | Snowball (JOI21_ho_t2) | C++14 | 118 ms | 16844 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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+1; i++){
if (i == q+1) x = 0;
else 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+1, d) - D;
int L = -l[id];
int R = r[id];
L = min(L, d);
R = min(R, d);
if (pos[id] == l[id]) L = min(L, d - R);
else if (pos[id] == r[id]) R = min(R, 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]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |