Submission #116646

# Submission time Handle Problem Language Result Execution time Memory
116646 2019-06-13T10:02:23 Z roseanne_pcy Boxes with souvenirs (IOI15_boxes) C++14
100 / 100
709 ms 249988 KB
#ifdef atom
#include "grader.cpp"
#else
#include "boxes.h"
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vvi vector< vi >
#define vii vector< ii >
#define mp make_pair
#define pb push_back
const int maxn = 1e7+5;
ll dp1[maxn];
ll dp2[maxn];
int a[maxn];
long long delivery(int n, int k, int l, int p[])
{
    for(int i = 1; i<= n; i++) a[i] = p[i-1];
    for(int i = 1; i<= k; i++) dp1[i] = 2*a[i];
    for(int i = n; i> n-k; i--) dp2[i] = 2*(l-a[i]);
    for(int i = k+1; i<= n; i++) dp1[i] = 2*a[i]+dp1[i-k];
    for(int i = n-k; i>= 1; i--) dp2[i] = 2*(l-a[i])+dp2[i+k];
    ll best = 1e18;
    for(int i = 0; i<= n; i++)
    {
        best = min(best, dp1[i]+dp2[i+1]);
    }
    //printf("%lld\n", best);
    for(int i = 1; i<= n; i++)
    {
        ll left = dp1[i-1];
        ll right = i+k<= n?dp2[i+k]:0;
        best = min(best, left+right+l);
    }
    return best;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 412 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 412 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 10 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 412 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 10 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 56 ms 33588 KB Output is correct
34 Correct 30 ms 25860 KB Output is correct
35 Correct 35 ms 26232 KB Output is correct
36 Correct 60 ms 33684 KB Output is correct
37 Correct 58 ms 33528 KB Output is correct
38 Correct 56 ms 33528 KB Output is correct
39 Correct 50 ms 32120 KB Output is correct
40 Correct 35 ms 27512 KB Output is correct
41 Correct 64 ms 33684 KB Output is correct
42 Correct 37 ms 27768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 412 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 10 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 56 ms 33588 KB Output is correct
34 Correct 30 ms 25860 KB Output is correct
35 Correct 35 ms 26232 KB Output is correct
36 Correct 60 ms 33684 KB Output is correct
37 Correct 58 ms 33528 KB Output is correct
38 Correct 56 ms 33528 KB Output is correct
39 Correct 50 ms 32120 KB Output is correct
40 Correct 35 ms 27512 KB Output is correct
41 Correct 64 ms 33684 KB Output is correct
42 Correct 37 ms 27768 KB Output is correct
43 Correct 709 ms 249524 KB Output is correct
44 Correct 296 ms 237128 KB Output is correct
45 Correct 375 ms 237208 KB Output is correct
46 Correct 567 ms 249988 KB Output is correct
47 Correct 599 ms 249596 KB Output is correct
48 Correct 582 ms 249588 KB Output is correct
49 Correct 516 ms 246648 KB Output is correct
50 Correct 357 ms 238808 KB Output is correct
51 Correct 548 ms 249340 KB Output is correct
52 Correct 343 ms 239992 KB Output is correct