//by szh
#include<bits/stdc++.h>
#include "boxes.h"
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
const int maxn = 1e7+10;
ll pre[maxn],suf[maxn];
ll sum[maxn];
long long delivery(int N, int K, int L, int p[]) {
memset(pre,0,sizeof(pre));
memset(suf,0,sizeof(suf));
rep(i,0,N) {
sum[i%K] += min(p[i]*2,L);
pre[i] = sum[i%K];
}
memset(sum,0,sizeof(sum));
for(int i=N-1;i>=0;i--) {
sum[(N-1-i)%K] += min((L-p[i])*2,L);
suf[i] = sum[(N-1-i)%K];
}
ll ans = min(suf[0],pre[N-1]);
rep(i,0,N-1) ans = min (ans,pre[i]+suf[i+1]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
235084 KB |
Output is correct |
2 |
Correct |
85 ms |
235116 KB |
Output is correct |
3 |
Correct |
85 ms |
235000 KB |
Output is correct |
4 |
Correct |
90 ms |
235072 KB |
Output is correct |
5 |
Correct |
87 ms |
235084 KB |
Output is correct |
6 |
Correct |
91 ms |
235128 KB |
Output is correct |
7 |
Correct |
92 ms |
235048 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
92 ms |
235036 KB |
Output is correct |
2 |
Correct |
87 ms |
235060 KB |
Output is correct |
3 |
Correct |
92 ms |
235088 KB |
Output is correct |
4 |
Correct |
96 ms |
235044 KB |
Output is correct |
5 |
Correct |
89 ms |
235208 KB |
Output is correct |
6 |
Correct |
90 ms |
235080 KB |
Output is correct |
7 |
Correct |
94 ms |
235016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
235156 KB |
Output is correct |
2 |
Correct |
88 ms |
235084 KB |
Output is correct |
3 |
Correct |
87 ms |
235080 KB |
Output is correct |
4 |
Correct |
88 ms |
235112 KB |
Output is correct |
5 |
Correct |
88 ms |
235064 KB |
Output is correct |
6 |
Correct |
90 ms |
235100 KB |
Output is correct |
7 |
Correct |
90 ms |
235008 KB |
Output is correct |
8 |
Correct |
91 ms |
235084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
235084 KB |
Output is correct |
2 |
Correct |
85 ms |
235116 KB |
Output is correct |
3 |
Correct |
85 ms |
235000 KB |
Output is correct |
4 |
Correct |
90 ms |
235072 KB |
Output is correct |
5 |
Correct |
87 ms |
235084 KB |
Output is correct |
6 |
Correct |
91 ms |
235128 KB |
Output is correct |
7 |
Correct |
92 ms |
235048 KB |
Output is correct |
8 |
Correct |
92 ms |
235036 KB |
Output is correct |
9 |
Correct |
87 ms |
235060 KB |
Output is correct |
10 |
Correct |
92 ms |
235088 KB |
Output is correct |
11 |
Correct |
96 ms |
235044 KB |
Output is correct |
12 |
Correct |
89 ms |
235208 KB |
Output is correct |
13 |
Correct |
90 ms |
235080 KB |
Output is correct |
14 |
Correct |
94 ms |
235016 KB |
Output is correct |
15 |
Correct |
90 ms |
235156 KB |
Output is correct |
16 |
Correct |
88 ms |
235084 KB |
Output is correct |
17 |
Correct |
87 ms |
235080 KB |
Output is correct |
18 |
Correct |
88 ms |
235112 KB |
Output is correct |
19 |
Correct |
88 ms |
235064 KB |
Output is correct |
20 |
Correct |
90 ms |
235100 KB |
Output is correct |
21 |
Correct |
90 ms |
235008 KB |
Output is correct |
22 |
Correct |
91 ms |
235084 KB |
Output is correct |
23 |
Correct |
88 ms |
235048 KB |
Output is correct |
24 |
Correct |
89 ms |
235084 KB |
Output is correct |
25 |
Correct |
87 ms |
235036 KB |
Output is correct |
26 |
Correct |
87 ms |
235076 KB |
Output is correct |
27 |
Correct |
86 ms |
235088 KB |
Output is correct |
28 |
Correct |
88 ms |
235172 KB |
Output is correct |
29 |
Correct |
87 ms |
235072 KB |
Output is correct |
30 |
Correct |
89 ms |
235128 KB |
Output is correct |
31 |
Correct |
89 ms |
235024 KB |
Output is correct |
32 |
Correct |
86 ms |
235032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
235084 KB |
Output is correct |
2 |
Correct |
85 ms |
235116 KB |
Output is correct |
3 |
Correct |
85 ms |
235000 KB |
Output is correct |
4 |
Correct |
90 ms |
235072 KB |
Output is correct |
5 |
Correct |
87 ms |
235084 KB |
Output is correct |
6 |
Correct |
91 ms |
235128 KB |
Output is correct |
7 |
Correct |
92 ms |
235048 KB |
Output is correct |
8 |
Correct |
92 ms |
235036 KB |
Output is correct |
9 |
Correct |
87 ms |
235060 KB |
Output is correct |
10 |
Correct |
92 ms |
235088 KB |
Output is correct |
11 |
Correct |
96 ms |
235044 KB |
Output is correct |
12 |
Correct |
89 ms |
235208 KB |
Output is correct |
13 |
Correct |
90 ms |
235080 KB |
Output is correct |
14 |
Correct |
94 ms |
235016 KB |
Output is correct |
15 |
Correct |
90 ms |
235156 KB |
Output is correct |
16 |
Correct |
88 ms |
235084 KB |
Output is correct |
17 |
Correct |
87 ms |
235080 KB |
Output is correct |
18 |
Correct |
88 ms |
235112 KB |
Output is correct |
19 |
Correct |
88 ms |
235064 KB |
Output is correct |
20 |
Correct |
90 ms |
235100 KB |
Output is correct |
21 |
Correct |
90 ms |
235008 KB |
Output is correct |
22 |
Correct |
91 ms |
235084 KB |
Output is correct |
23 |
Correct |
88 ms |
235048 KB |
Output is correct |
24 |
Correct |
89 ms |
235084 KB |
Output is correct |
25 |
Correct |
87 ms |
235036 KB |
Output is correct |
26 |
Correct |
87 ms |
235076 KB |
Output is correct |
27 |
Correct |
86 ms |
235088 KB |
Output is correct |
28 |
Correct |
88 ms |
235172 KB |
Output is correct |
29 |
Correct |
87 ms |
235072 KB |
Output is correct |
30 |
Correct |
89 ms |
235128 KB |
Output is correct |
31 |
Correct |
89 ms |
235024 KB |
Output is correct |
32 |
Correct |
86 ms |
235032 KB |
Output is correct |
33 |
Correct |
138 ms |
248720 KB |
Output is correct |
34 |
Correct |
108 ms |
240892 KB |
Output is correct |
35 |
Correct |
115 ms |
241412 KB |
Output is correct |
36 |
Correct |
154 ms |
248724 KB |
Output is correct |
37 |
Correct |
151 ms |
248900 KB |
Output is correct |
38 |
Correct |
140 ms |
248764 KB |
Output is correct |
39 |
Correct |
133 ms |
247284 KB |
Output is correct |
40 |
Correct |
122 ms |
242652 KB |
Output is correct |
41 |
Correct |
146 ms |
248832 KB |
Output is correct |
42 |
Correct |
115 ms |
242948 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
88 ms |
235084 KB |
Output is correct |
2 |
Correct |
85 ms |
235116 KB |
Output is correct |
3 |
Correct |
85 ms |
235000 KB |
Output is correct |
4 |
Correct |
90 ms |
235072 KB |
Output is correct |
5 |
Correct |
87 ms |
235084 KB |
Output is correct |
6 |
Correct |
91 ms |
235128 KB |
Output is correct |
7 |
Correct |
92 ms |
235048 KB |
Output is correct |
8 |
Correct |
92 ms |
235036 KB |
Output is correct |
9 |
Correct |
87 ms |
235060 KB |
Output is correct |
10 |
Correct |
92 ms |
235088 KB |
Output is correct |
11 |
Correct |
96 ms |
235044 KB |
Output is correct |
12 |
Correct |
89 ms |
235208 KB |
Output is correct |
13 |
Correct |
90 ms |
235080 KB |
Output is correct |
14 |
Correct |
94 ms |
235016 KB |
Output is correct |
15 |
Correct |
90 ms |
235156 KB |
Output is correct |
16 |
Correct |
88 ms |
235084 KB |
Output is correct |
17 |
Correct |
87 ms |
235080 KB |
Output is correct |
18 |
Correct |
88 ms |
235112 KB |
Output is correct |
19 |
Correct |
88 ms |
235064 KB |
Output is correct |
20 |
Correct |
90 ms |
235100 KB |
Output is correct |
21 |
Correct |
90 ms |
235008 KB |
Output is correct |
22 |
Correct |
91 ms |
235084 KB |
Output is correct |
23 |
Correct |
88 ms |
235048 KB |
Output is correct |
24 |
Correct |
89 ms |
235084 KB |
Output is correct |
25 |
Correct |
87 ms |
235036 KB |
Output is correct |
26 |
Correct |
87 ms |
235076 KB |
Output is correct |
27 |
Correct |
86 ms |
235088 KB |
Output is correct |
28 |
Correct |
88 ms |
235172 KB |
Output is correct |
29 |
Correct |
87 ms |
235072 KB |
Output is correct |
30 |
Correct |
89 ms |
235128 KB |
Output is correct |
31 |
Correct |
89 ms |
235024 KB |
Output is correct |
32 |
Correct |
86 ms |
235032 KB |
Output is correct |
33 |
Correct |
138 ms |
248720 KB |
Output is correct |
34 |
Correct |
108 ms |
240892 KB |
Output is correct |
35 |
Correct |
115 ms |
241412 KB |
Output is correct |
36 |
Correct |
154 ms |
248724 KB |
Output is correct |
37 |
Correct |
151 ms |
248900 KB |
Output is correct |
38 |
Correct |
140 ms |
248764 KB |
Output is correct |
39 |
Correct |
133 ms |
247284 KB |
Output is correct |
40 |
Correct |
122 ms |
242652 KB |
Output is correct |
41 |
Correct |
146 ms |
248832 KB |
Output is correct |
42 |
Correct |
115 ms |
242948 KB |
Output is correct |
43 |
Correct |
644 ms |
337476 KB |
Output is correct |
44 |
Correct |
309 ms |
293796 KB |
Output is correct |
45 |
Correct |
378 ms |
301604 KB |
Output is correct |
46 |
Correct |
620 ms |
339128 KB |
Output is correct |
47 |
Correct |
649 ms |
339272 KB |
Output is correct |
48 |
Correct |
658 ms |
339636 KB |
Output is correct |
49 |
Correct |
571 ms |
328108 KB |
Output is correct |
50 |
Correct |
357 ms |
292612 KB |
Output is correct |
51 |
Correct |
634 ms |
339268 KB |
Output is correct |
52 |
Correct |
373 ms |
292960 KB |
Output is correct |