#include "boxes.h"
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
//~ ll s1[10000100],s2[10000100];
long long delivery(int N, int K, int L, int p[]) {
ll Min=INF;
for(int i=0;i<=N;i++){
//[0,i) [i,N)
int cnt=0;
ll sum=0;
for(int j=i-1;j>=0;j--){
if(cnt==0)sum+=min(p[j],L-p[j]);
else sum+=p[j+1]-p[j];
cnt++;
if(cnt==K||j==0){
sum+=min(p[j],L-p[j]);
cnt=0;
}
}
for(int j=i;j<N;j++){
if(cnt==0)sum+=min(p[j],L-p[j]);
else sum+=p[j]-p[j-1];
cnt++;
if(cnt==K||j==N-1){
sum+=min(p[j],L-p[j]);
cnt=0;
}
}
Min=min(Min,sum);
}
return Min;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
256 KB |
Output is correct |
3 |
Correct |
7 ms |
248 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
256 KB |
Output is correct |
2 |
Correct |
6 ms |
248 KB |
Output is correct |
3 |
Correct |
6 ms |
256 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
6 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
380 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
256 KB |
Output is correct |
3 |
Correct |
7 ms |
248 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
6 ms |
248 KB |
Output is correct |
10 |
Correct |
6 ms |
256 KB |
Output is correct |
11 |
Correct |
6 ms |
256 KB |
Output is correct |
12 |
Correct |
6 ms |
256 KB |
Output is correct |
13 |
Correct |
6 ms |
256 KB |
Output is correct |
14 |
Correct |
6 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
380 KB |
Output is correct |
19 |
Correct |
6 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
6 ms |
256 KB |
Output is correct |
24 |
Correct |
8 ms |
256 KB |
Output is correct |
25 |
Correct |
7 ms |
360 KB |
Output is correct |
26 |
Correct |
24 ms |
256 KB |
Output is correct |
27 |
Correct |
6 ms |
256 KB |
Output is correct |
28 |
Correct |
6 ms |
256 KB |
Output is correct |
29 |
Correct |
6 ms |
256 KB |
Output is correct |
30 |
Correct |
6 ms |
256 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
6 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
256 KB |
Output is correct |
3 |
Correct |
7 ms |
248 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
6 ms |
248 KB |
Output is correct |
10 |
Correct |
6 ms |
256 KB |
Output is correct |
11 |
Correct |
6 ms |
256 KB |
Output is correct |
12 |
Correct |
6 ms |
256 KB |
Output is correct |
13 |
Correct |
6 ms |
256 KB |
Output is correct |
14 |
Correct |
6 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
380 KB |
Output is correct |
19 |
Correct |
6 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
6 ms |
256 KB |
Output is correct |
24 |
Correct |
8 ms |
256 KB |
Output is correct |
25 |
Correct |
7 ms |
360 KB |
Output is correct |
26 |
Correct |
24 ms |
256 KB |
Output is correct |
27 |
Correct |
6 ms |
256 KB |
Output is correct |
28 |
Correct |
6 ms |
256 KB |
Output is correct |
29 |
Correct |
6 ms |
256 KB |
Output is correct |
30 |
Correct |
6 ms |
256 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
6 ms |
256 KB |
Output is correct |
33 |
Execution timed out |
2098 ms |
4216 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
7 ms |
256 KB |
Output is correct |
3 |
Correct |
7 ms |
248 KB |
Output is correct |
4 |
Correct |
7 ms |
256 KB |
Output is correct |
5 |
Correct |
7 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
256 KB |
Output is correct |
7 |
Correct |
7 ms |
256 KB |
Output is correct |
8 |
Correct |
6 ms |
256 KB |
Output is correct |
9 |
Correct |
6 ms |
248 KB |
Output is correct |
10 |
Correct |
6 ms |
256 KB |
Output is correct |
11 |
Correct |
6 ms |
256 KB |
Output is correct |
12 |
Correct |
6 ms |
256 KB |
Output is correct |
13 |
Correct |
6 ms |
256 KB |
Output is correct |
14 |
Correct |
6 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
5 ms |
380 KB |
Output is correct |
19 |
Correct |
6 ms |
376 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
376 KB |
Output is correct |
23 |
Correct |
6 ms |
256 KB |
Output is correct |
24 |
Correct |
8 ms |
256 KB |
Output is correct |
25 |
Correct |
7 ms |
360 KB |
Output is correct |
26 |
Correct |
24 ms |
256 KB |
Output is correct |
27 |
Correct |
6 ms |
256 KB |
Output is correct |
28 |
Correct |
6 ms |
256 KB |
Output is correct |
29 |
Correct |
6 ms |
256 KB |
Output is correct |
30 |
Correct |
6 ms |
256 KB |
Output is correct |
31 |
Correct |
6 ms |
376 KB |
Output is correct |
32 |
Correct |
6 ms |
256 KB |
Output is correct |
33 |
Execution timed out |
2098 ms |
4216 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |