Submission #868744

# Submission time Handle Problem Language Result Execution time Memory
868744 2023-11-01T21:24:45 Z dpsaveslives Boxes with souvenirs (IOI15_boxes) C++17
100 / 100
477 ms 334644 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll delivery(int N, int K, int L, int positions[]){
    vector<int> arr; arr.push_back(0);
    for(int i = 0;i<N;++i) arr.push_back(positions[i]);
    vector<ll> pref(N+2,0),suf(N+2,0);
    for(int i = 1;i<=N;++i){
        pref[i] = arr[i]*2LL + (i > K ? pref[i-K] : 0);
    }
    for(int i = N;i>=1;--i){
        suf[i] = (L-arr[i])*2LL + (i > N-K+1 ? 0 : suf[i+K]);
    }
    ll ans = suf[1];
    for(int i = 0;i<=N;++i){
        ans = min(ans,pref[i]+suf[i+1]);
        if(i+K <= N) ans = min(ans,pref[i]+L+suf[i+K+1]);
        else ans = min(ans,pref[i]+L);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 444 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 440 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 444 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 440 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 436 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 444 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 440 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 436 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 44 ms 33724 KB Output is correct
34 Correct 17 ms 25800 KB Output is correct
35 Correct 19 ms 26280 KB Output is correct
36 Correct 45 ms 33684 KB Output is correct
37 Correct 44 ms 33608 KB Output is correct
38 Correct 44 ms 33668 KB Output is correct
39 Correct 40 ms 32112 KB Output is correct
40 Correct 24 ms 27704 KB Output is correct
41 Correct 43 ms 33728 KB Output is correct
42 Correct 25 ms 27912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 444 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 440 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 436 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 44 ms 33724 KB Output is correct
34 Correct 17 ms 25800 KB Output is correct
35 Correct 19 ms 26280 KB Output is correct
36 Correct 45 ms 33684 KB Output is correct
37 Correct 44 ms 33608 KB Output is correct
38 Correct 44 ms 33668 KB Output is correct
39 Correct 40 ms 32112 KB Output is correct
40 Correct 24 ms 27704 KB Output is correct
41 Correct 43 ms 33728 KB Output is correct
42 Correct 25 ms 27912 KB Output is correct
43 Correct 477 ms 332752 KB Output is correct
44 Correct 193 ms 255388 KB Output is correct
45 Correct 218 ms 263204 KB Output is correct
46 Correct 455 ms 333468 KB Output is correct
47 Correct 462 ms 334568 KB Output is correct
48 Correct 463 ms 334392 KB Output is correct
49 Correct 414 ms 318144 KB Output is correct
50 Correct 251 ms 272716 KB Output is correct
51 Correct 461 ms 334644 KB Output is correct
52 Correct 241 ms 275344 KB Output is correct