Submission #189247

# Submission time Handle Problem Language Result Execution time Memory
189247 2020-01-14T00:05:38 Z AQT Boxes with souvenirs (IOI15_boxes) C++14
100 / 100
552 ms 137208 KB
#include <bits/stdc++.h>

using namespace std;

long long delivery(int N, int K, int L, int arr[]){
    long long ans = LLONG_MAX;
    for(int k = 0; k<K; k++){
        long long cnt = 0;
        bool b = 0;
        for(int i = k; i-K+1 < N; i+=K){
            if(arr[(i < N ? i : N-1)]*2 >= L){
                b = 1;
            }
            if(arr[(i-K+1 > 0 ? i-K+1 : 0)]*2 <= L && arr[(i < N ? i : N-1)]*2 >= L){
                cnt += L;
            }
            else if(b){
                cnt += (L-arr[(i-K+1 > 0 ? i-K+1 : 0)])*2;
            }
            else{
                cnt += arr[(i < N ? i : N-1)]*2;
            }
        }
        ans = (cnt < ans ? cnt : ans);
    }
    return ans;
}

/*
int main(){
    int arr[3] = {1, 2, 5};
    cout << delivery(3, 2, 8, arr) << endl;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 1 ms 128 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 1 ms 128 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 1 ms 128 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 49 ms 13944 KB Output is correct
34 Correct 18 ms 6264 KB Output is correct
35 Correct 18 ms 6768 KB Output is correct
36 Correct 52 ms 13944 KB Output is correct
37 Correct 50 ms 14072 KB Output is correct
38 Correct 49 ms 13944 KB Output is correct
39 Correct 44 ms 12536 KB Output is correct
40 Correct 29 ms 7928 KB Output is correct
41 Correct 53 ms 14072 KB Output is correct
42 Correct 25 ms 8184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 1 ms 128 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 256 KB Output is correct
21 Correct 2 ms 380 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 256 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 49 ms 13944 KB Output is correct
34 Correct 18 ms 6264 KB Output is correct
35 Correct 18 ms 6768 KB Output is correct
36 Correct 52 ms 13944 KB Output is correct
37 Correct 50 ms 14072 KB Output is correct
38 Correct 49 ms 13944 KB Output is correct
39 Correct 44 ms 12536 KB Output is correct
40 Correct 29 ms 7928 KB Output is correct
41 Correct 53 ms 14072 KB Output is correct
42 Correct 25 ms 8184 KB Output is correct
43 Correct 454 ms 136060 KB Output is correct
44 Correct 142 ms 59016 KB Output is correct
45 Correct 187 ms 66808 KB Output is correct
46 Correct 467 ms 137208 KB Output is correct
47 Correct 472 ms 137164 KB Output is correct
48 Correct 552 ms 137172 KB Output is correct
49 Correct 398 ms 121976 KB Output is correct
50 Correct 201 ms 75956 KB Output is correct
51 Correct 472 ms 137136 KB Output is correct
52 Correct 228 ms 78588 KB Output is correct