Submission #198883

# Submission time Handle Problem Language Result Execution time Memory
198883 2020-01-28T01:52:48 Z Sakamotoo Boxes with souvenirs (IOI15_boxes) C++14
70 / 100
2000 ms 131704 KB
#include "boxes.h"
#include<bits/stdc++.h>
using namespace std;

long long delivery(int n, int k, int l, int p[]) {
	long long dp1[n+1],dp2[n+1];
    long long jaw=1e18;
    dp1[0]=0;
    dp2[0]=0;
    sort(p,p+n);
    for(int i=0; i<n; i++){
    	int x=i-k+1;
    	if(x<0){
    		int y=n-i-1;
    		dp1[i+1]=p[i]+min(p[i],l-p[i]);
    		dp2[i+1]=l-p[y]+min(p[y],l-p[y]);
		}else {
			int y=n-i-1;
			dp1[i+1]=dp1[x]+p[i]+min(p[i],l-p[i]);
			dp2[i+1]=dp2[x]+l-p[y]+min(p[y],l-p[y]);
		}
		//cout<<dp1[i+1]<<' '<<dp2[i+1]<<endl;
	}
	for(int i=0; i<=n; i++){
		jaw=min(jaw,dp1[i]+dp2[n-i]);
	}
	return jaw;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 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 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 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 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 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 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 364 KB Output is correct
33 Correct 93 ms 29756 KB Output is correct
34 Correct 42 ms 21924 KB Output is correct
35 Correct 46 ms 22396 KB Output is correct
36 Correct 82 ms 29820 KB Output is correct
37 Correct 80 ms 29720 KB Output is correct
38 Correct 79 ms 29688 KB Output is correct
39 Correct 80 ms 28196 KB Output is correct
40 Correct 53 ms 23544 KB Output is correct
41 Correct 88 ms 29688 KB Output is correct
42 Correct 54 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 380 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 256 KB Output is correct
19 Correct 5 ms 256 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 256 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 5 ms 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 376 KB Output is correct
32 Correct 5 ms 364 KB Output is correct
33 Correct 93 ms 29756 KB Output is correct
34 Correct 42 ms 21924 KB Output is correct
35 Correct 46 ms 22396 KB Output is correct
36 Correct 82 ms 29820 KB Output is correct
37 Correct 80 ms 29720 KB Output is correct
38 Correct 79 ms 29688 KB Output is correct
39 Correct 80 ms 28196 KB Output is correct
40 Correct 53 ms 23544 KB Output is correct
41 Correct 88 ms 29688 KB Output is correct
42 Correct 54 ms 23800 KB Output is correct
43 Execution timed out 2138 ms 131704 KB Time limit exceeded
44 Halted 0 ms 0 KB -