| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 620816 | patrikpavic2 | Snowball (JOI21_ho_t2) | C++17 | 138 ms | 15308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 2e5 + 500;
typedef long long ll;
int n, q;
ll A[N], w[N];
ll dpL[N], dpR[N], ans[N];
int main(){
scanf("%d%d", &n, &q);
for(int i = 0;i < n;i++)
scanf("%lld", A + i);
for(int i = 1;i <= q;i++)
scanf("%lld", w + i);
ll cur = 0;
for(int i = 1;i <= q;i++){
cur += w[i];
dpL[i] = min(dpL[i - 1], cur);
dpR[i] = max(dpR[i - 1], cur);
}
ans[0] -= dpL[q]; ans[n - 1] += dpR[q];
for(int i = 0;i + 1 < n;i++){
ll raz = A[i + 1] - A[i];
int j = 0;
for(int k = 17;k >= 0;k--){
if(j + (1 << k) > q) continue;
if(-dpL[j + (1 << k)] + dpR[j + (1 << k)] <= raz)
j += (1 << k);
}
ans[i] += dpR[j];
ans[i + 1] -= dpL[j];
if(j < q){
if(w[j + 1] > 0)
ans[i] += raz + dpL[j] - dpR[j];
else
ans[i + 1] += raz + dpL[j] - dpR[j];
}
}
for(int i = 0;i < n;i++)
printf("%lld\n", ans[i]);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
