# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
862156 | 2023-10-17T14:53:28 Z | vjudge1 | Snowball (JOI21_ho_t2) | C++17 | 98 ms | 15488 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define F first #define S second #define endl '\n' #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() const int mod = 1e9 + 7; const int N = 2e5 + 15; const ll inf = 1e18; int n, q; ll X[N], W[N]; ll mn[N], mx[N]; ll ans[N]; int main(){ scanf("%d%d", &n, &q); X[0] = -inf, X[n+1] = inf; for (int i=1;i<=n;i++){ scanf("%lld", X+i); } ll prf=0; for (int i=1;i<=q;i++){ scanf("%lld", W+i); prf += W[i]; mn[i] = min(mn[i-1], prf); mx[i] = max(mx[i-1], prf); } ll D = -mn[q] + mx[q]; ans[1] += -mn[q]; ans[n] += mx[q]; for (int i=1;i<=n-1;i++){ ll dis = X[i+1]-X[i]; if (dis >= D){ ans[i] += mx[q]; ans[i+1] += -mn[q]; continue; } // the touch each other int L=0, R=q; while (R-L>1){ int M = (L+R)>>1; if (mx[M] + -mn[M] >= dis){ R = M; } else { L = M; } } if (mx[L]==mx[R]){// the min moved ans[i] += mx[L]; ans[i+1] += dis-mx[L]; } else { ans[i+1] += -mn[L]; ans[i] += dis+mn[L]; } } for (int i=1;i<=n;i++){ printf("%lld\n", ans[i]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2504 KB | Output is correct |
6 | Correct | 1 ms | 2392 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 2 ms | 2648 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2504 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2396 KB | Output is correct |
4 | Correct | 1 ms | 2396 KB | Output is correct |
5 | Correct | 1 ms | 2504 KB | Output is correct |
6 | Correct | 1 ms | 2392 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 2 ms | 2648 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2504 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 1 ms | 2396 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 20 ms | 7256 KB | Output is correct |
21 | Correct | 19 ms | 6920 KB | Output is correct |
22 | Correct | 19 ms | 6748 KB | Output is correct |
23 | Correct | 23 ms | 7004 KB | Output is correct |
24 | Correct | 24 ms | 6992 KB | Output is correct |
25 | Correct | 82 ms | 13340 KB | Output is correct |
26 | Correct | 80 ms | 13420 KB | Output is correct |
27 | Correct | 79 ms | 13136 KB | Output is correct |
28 | Correct | 78 ms | 13292 KB | Output is correct |
29 | Correct | 78 ms | 12584 KB | Output is correct |
30 | Correct | 77 ms | 12072 KB | Output is correct |
31 | Correct | 61 ms | 11604 KB | Output is correct |
32 | Correct | 45 ms | 11600 KB | Output is correct |
33 | Correct | 7 ms | 3420 KB | Output is correct |
34 | Correct | 98 ms | 13720 KB | Output is correct |
35 | Correct | 81 ms | 13136 KB | Output is correct |
36 | Correct | 81 ms | 13304 KB | Output is correct |
37 | Correct | 79 ms | 13140 KB | Output is correct |
38 | Correct | 78 ms | 12940 KB | Output is correct |
39 | Correct | 79 ms | 13308 KB | Output is correct |
40 | Correct | 67 ms | 13344 KB | Output is correct |
41 | Correct | 21 ms | 7768 KB | Output is correct |
42 | Correct | 45 ms | 11600 KB | Output is correct |
43 | Correct | 66 ms | 15044 KB | Output is correct |
44 | Correct | 21 ms | 7760 KB | Output is correct |
45 | Correct | 50 ms | 13136 KB | Output is correct |
46 | Correct | 66 ms | 15188 KB | Output is correct |
47 | Correct | 69 ms | 15184 KB | Output is correct |
48 | Correct | 66 ms | 15488 KB | Output is correct |