#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e7+5;
ll mod[MAXN];
ll pre[MAXN], pos[MAXN];
ll delivery(int n, int k, int x, int v[]) {
// if(n>1000001) return -1;
for(int i=0; i<n; i++) {
ll val=v[i]; val*=2; val=min(val, (ll) x);
int ind=i%k;
if(ind<0) return -1;
mod[ind]+=val;
pre[i]=mod[ind];
}
memset(mod, 0, sizeof(mod));
for(int i=n-1; i>=0; i--) {
ll val=x-v[i]; val*=2; val=min(val, (ll) x);
int ind=i%k;
if(ind<0) return -1;
mod[ind]+=val;
pos[i]=mod[ind];
}
ll resp=x; resp*=n;
for(int i=0; i<n; i++) resp=min(resp, pre[i]+pos[i+1]);
resp=min(resp, pos[0]);
return resp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
78840 KB |
Output is correct |
2 |
Correct |
68 ms |
78660 KB |
Output is correct |
3 |
Correct |
71 ms |
78712 KB |
Output is correct |
4 |
Correct |
62 ms |
78584 KB |
Output is correct |
5 |
Correct |
58 ms |
78584 KB |
Output is correct |
6 |
Correct |
60 ms |
78756 KB |
Output is correct |
7 |
Correct |
61 ms |
78584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
78584 KB |
Output is correct |
2 |
Correct |
60 ms |
78640 KB |
Output is correct |
3 |
Correct |
58 ms |
78584 KB |
Output is correct |
4 |
Correct |
62 ms |
78584 KB |
Output is correct |
5 |
Correct |
60 ms |
78584 KB |
Output is correct |
6 |
Correct |
68 ms |
78760 KB |
Output is correct |
7 |
Correct |
65 ms |
78712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
78552 KB |
Output is correct |
2 |
Correct |
68 ms |
78676 KB |
Output is correct |
3 |
Correct |
58 ms |
78616 KB |
Output is correct |
4 |
Correct |
64 ms |
78584 KB |
Output is correct |
5 |
Correct |
67 ms |
78664 KB |
Output is correct |
6 |
Correct |
67 ms |
78572 KB |
Output is correct |
7 |
Correct |
73 ms |
78584 KB |
Output is correct |
8 |
Correct |
64 ms |
78600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
78840 KB |
Output is correct |
2 |
Correct |
68 ms |
78660 KB |
Output is correct |
3 |
Correct |
71 ms |
78712 KB |
Output is correct |
4 |
Correct |
62 ms |
78584 KB |
Output is correct |
5 |
Correct |
58 ms |
78584 KB |
Output is correct |
6 |
Correct |
60 ms |
78756 KB |
Output is correct |
7 |
Correct |
61 ms |
78584 KB |
Output is correct |
8 |
Correct |
60 ms |
78584 KB |
Output is correct |
9 |
Correct |
60 ms |
78640 KB |
Output is correct |
10 |
Correct |
58 ms |
78584 KB |
Output is correct |
11 |
Correct |
62 ms |
78584 KB |
Output is correct |
12 |
Correct |
60 ms |
78584 KB |
Output is correct |
13 |
Correct |
68 ms |
78760 KB |
Output is correct |
14 |
Correct |
65 ms |
78712 KB |
Output is correct |
15 |
Correct |
63 ms |
78552 KB |
Output is correct |
16 |
Correct |
68 ms |
78676 KB |
Output is correct |
17 |
Correct |
58 ms |
78616 KB |
Output is correct |
18 |
Correct |
64 ms |
78584 KB |
Output is correct |
19 |
Correct |
67 ms |
78664 KB |
Output is correct |
20 |
Correct |
67 ms |
78572 KB |
Output is correct |
21 |
Correct |
73 ms |
78584 KB |
Output is correct |
22 |
Correct |
64 ms |
78600 KB |
Output is correct |
23 |
Correct |
68 ms |
78584 KB |
Output is correct |
24 |
Correct |
65 ms |
78584 KB |
Output is correct |
25 |
Correct |
57 ms |
78632 KB |
Output is correct |
26 |
Correct |
57 ms |
78584 KB |
Output is correct |
27 |
Correct |
59 ms |
78584 KB |
Output is correct |
28 |
Correct |
63 ms |
78712 KB |
Output is correct |
29 |
Correct |
57 ms |
78584 KB |
Output is correct |
30 |
Correct |
60 ms |
78576 KB |
Output is correct |
31 |
Correct |
62 ms |
78712 KB |
Output is correct |
32 |
Correct |
68 ms |
78712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
78840 KB |
Output is correct |
2 |
Correct |
68 ms |
78660 KB |
Output is correct |
3 |
Correct |
71 ms |
78712 KB |
Output is correct |
4 |
Correct |
62 ms |
78584 KB |
Output is correct |
5 |
Correct |
58 ms |
78584 KB |
Output is correct |
6 |
Correct |
60 ms |
78756 KB |
Output is correct |
7 |
Correct |
61 ms |
78584 KB |
Output is correct |
8 |
Correct |
60 ms |
78584 KB |
Output is correct |
9 |
Correct |
60 ms |
78640 KB |
Output is correct |
10 |
Correct |
58 ms |
78584 KB |
Output is correct |
11 |
Correct |
62 ms |
78584 KB |
Output is correct |
12 |
Correct |
60 ms |
78584 KB |
Output is correct |
13 |
Correct |
68 ms |
78760 KB |
Output is correct |
14 |
Correct |
65 ms |
78712 KB |
Output is correct |
15 |
Correct |
63 ms |
78552 KB |
Output is correct |
16 |
Correct |
68 ms |
78676 KB |
Output is correct |
17 |
Correct |
58 ms |
78616 KB |
Output is correct |
18 |
Correct |
64 ms |
78584 KB |
Output is correct |
19 |
Correct |
67 ms |
78664 KB |
Output is correct |
20 |
Correct |
67 ms |
78572 KB |
Output is correct |
21 |
Correct |
73 ms |
78584 KB |
Output is correct |
22 |
Correct |
64 ms |
78600 KB |
Output is correct |
23 |
Correct |
68 ms |
78584 KB |
Output is correct |
24 |
Correct |
65 ms |
78584 KB |
Output is correct |
25 |
Correct |
57 ms |
78632 KB |
Output is correct |
26 |
Correct |
57 ms |
78584 KB |
Output is correct |
27 |
Correct |
59 ms |
78584 KB |
Output is correct |
28 |
Correct |
63 ms |
78712 KB |
Output is correct |
29 |
Correct |
57 ms |
78584 KB |
Output is correct |
30 |
Correct |
60 ms |
78576 KB |
Output is correct |
31 |
Correct |
62 ms |
78712 KB |
Output is correct |
32 |
Correct |
68 ms |
78712 KB |
Output is correct |
33 |
Correct |
120 ms |
107948 KB |
Output is correct |
34 |
Correct |
97 ms |
100216 KB |
Output is correct |
35 |
Correct |
90 ms |
100688 KB |
Output is correct |
36 |
Correct |
136 ms |
107980 KB |
Output is correct |
37 |
Correct |
126 ms |
108032 KB |
Output is correct |
38 |
Correct |
123 ms |
108024 KB |
Output is correct |
39 |
Correct |
114 ms |
106444 KB |
Output is correct |
40 |
Correct |
103 ms |
101880 KB |
Output is correct |
41 |
Correct |
127 ms |
108024 KB |
Output is correct |
42 |
Correct |
97 ms |
102108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
78840 KB |
Output is correct |
2 |
Correct |
68 ms |
78660 KB |
Output is correct |
3 |
Correct |
71 ms |
78712 KB |
Output is correct |
4 |
Correct |
62 ms |
78584 KB |
Output is correct |
5 |
Correct |
58 ms |
78584 KB |
Output is correct |
6 |
Correct |
60 ms |
78756 KB |
Output is correct |
7 |
Correct |
61 ms |
78584 KB |
Output is correct |
8 |
Correct |
60 ms |
78584 KB |
Output is correct |
9 |
Correct |
60 ms |
78640 KB |
Output is correct |
10 |
Correct |
58 ms |
78584 KB |
Output is correct |
11 |
Correct |
62 ms |
78584 KB |
Output is correct |
12 |
Correct |
60 ms |
78584 KB |
Output is correct |
13 |
Correct |
68 ms |
78760 KB |
Output is correct |
14 |
Correct |
65 ms |
78712 KB |
Output is correct |
15 |
Correct |
63 ms |
78552 KB |
Output is correct |
16 |
Correct |
68 ms |
78676 KB |
Output is correct |
17 |
Correct |
58 ms |
78616 KB |
Output is correct |
18 |
Correct |
64 ms |
78584 KB |
Output is correct |
19 |
Correct |
67 ms |
78664 KB |
Output is correct |
20 |
Correct |
67 ms |
78572 KB |
Output is correct |
21 |
Correct |
73 ms |
78584 KB |
Output is correct |
22 |
Correct |
64 ms |
78600 KB |
Output is correct |
23 |
Correct |
68 ms |
78584 KB |
Output is correct |
24 |
Correct |
65 ms |
78584 KB |
Output is correct |
25 |
Correct |
57 ms |
78632 KB |
Output is correct |
26 |
Correct |
57 ms |
78584 KB |
Output is correct |
27 |
Correct |
59 ms |
78584 KB |
Output is correct |
28 |
Correct |
63 ms |
78712 KB |
Output is correct |
29 |
Correct |
57 ms |
78584 KB |
Output is correct |
30 |
Correct |
60 ms |
78576 KB |
Output is correct |
31 |
Correct |
62 ms |
78712 KB |
Output is correct |
32 |
Correct |
68 ms |
78712 KB |
Output is correct |
33 |
Correct |
120 ms |
107948 KB |
Output is correct |
34 |
Correct |
97 ms |
100216 KB |
Output is correct |
35 |
Correct |
90 ms |
100688 KB |
Output is correct |
36 |
Correct |
136 ms |
107980 KB |
Output is correct |
37 |
Correct |
126 ms |
108032 KB |
Output is correct |
38 |
Correct |
123 ms |
108024 KB |
Output is correct |
39 |
Correct |
114 ms |
106444 KB |
Output is correct |
40 |
Correct |
103 ms |
101880 KB |
Output is correct |
41 |
Correct |
127 ms |
108024 KB |
Output is correct |
42 |
Correct |
97 ms |
102108 KB |
Output is correct |
43 |
Correct |
806 ms |
371336 KB |
Output is correct |
44 |
Correct |
414 ms |
294032 KB |
Output is correct |
45 |
Correct |
422 ms |
301692 KB |
Output is correct |
46 |
Correct |
686 ms |
372316 KB |
Output is correct |
47 |
Correct |
719 ms |
372288 KB |
Output is correct |
48 |
Correct |
778 ms |
372420 KB |
Output is correct |
49 |
Correct |
699 ms |
357060 KB |
Output is correct |
50 |
Correct |
474 ms |
310940 KB |
Output is correct |
51 |
Correct |
705 ms |
372208 KB |
Output is correct |
52 |
Correct |
472 ms |
313592 KB |
Output is correct |