Submission #537829

# Submission time Handle Problem Language Result Execution time Memory
537829 2022-03-15T16:17:55 Z timreizin Boxes with souvenirs (IOI15_boxes) C++17
100 / 100
809 ms 334148 KB
#include "boxes.h"
#include <vector>

using namespace std;

using ll = long long;

ll compute(vector<ll> &a, int k)
{
    ll res = 0;
    for (int i = (int)a.size() - 1; i >= 0; i -= k) res += a[i] * 2;
    return res;
}

long long delivery(int n, int k, int l, int P[])
{
    vector<ll> teams(n);
    for (int i = 0; i < n; ++i) teams[i] = P[i];
    vector<ll> side, left;
    while (!teams.empty() && l - teams.back() < teams.back())
    {
        side.push_back(l - teams.back());
        teams.pop_back();
    }
    ll minRes = compute(teams, k) + compute(side, k);
    for (int i = 0; i < k && !side.empty(); ++i)
    {
        left.push_back(side.back());
        side.pop_back();
    }
    for (int i = 0; i <= k; ++i)
    {
        if (k - i < left.size())
        {
            side.push_back(left.back());
            left.pop_back();
        }
        minRes = min(minRes, compute(teams, k) + compute(side, k) + l);
        if (!teams.empty()) teams.pop_back();
    }
    return minRes;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (k - i < left.size())
      |             ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 284 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 284 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 288 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 292 KB Output is correct
29 Correct 1 ms 292 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 284 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 288 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 292 KB Output is correct
29 Correct 1 ms 292 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 62 ms 25972 KB Output is correct
34 Correct 20 ms 18108 KB Output is correct
35 Correct 29 ms 18620 KB Output is correct
36 Correct 57 ms 30164 KB Output is correct
37 Correct 68 ms 30164 KB Output is correct
38 Correct 59 ms 23960 KB Output is correct
39 Correct 49 ms 24456 KB Output is correct
40 Correct 28 ms 19848 KB Output is correct
41 Correct 67 ms 30112 KB Output is correct
42 Correct 34 ms 24256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 284 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 288 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 292 KB Output is correct
29 Correct 1 ms 292 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 62 ms 25972 KB Output is correct
34 Correct 20 ms 18108 KB Output is correct
35 Correct 29 ms 18620 KB Output is correct
36 Correct 57 ms 30164 KB Output is correct
37 Correct 68 ms 30164 KB Output is correct
38 Correct 59 ms 23960 KB Output is correct
39 Correct 49 ms 24456 KB Output is correct
40 Correct 28 ms 19848 KB Output is correct
41 Correct 67 ms 30112 KB Output is correct
42 Correct 34 ms 24256 KB Output is correct
43 Correct 579 ms 279952 KB Output is correct
44 Correct 199 ms 176764 KB Output is correct
45 Correct 267 ms 210796 KB Output is correct
46 Correct 504 ms 215560 KB Output is correct
47 Correct 652 ms 273144 KB Output is correct
48 Correct 809 ms 334148 KB Output is correct
49 Correct 521 ms 264448 KB Output is correct
50 Correct 316 ms 218408 KB Output is correct
51 Correct 701 ms 328216 KB Output is correct
52 Correct 403 ms 286224 KB Output is correct