Submission #238001

# Submission time Handle Problem Language Result Execution time Memory
238001 2020-06-09T16:30:34 Z Kubin Boxes with souvenirs (IOI15_boxes) C++11
20 / 100
6 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

long long delivery(int _n, int _k, int l, int p[])
{
    size_t n = _n, k = _k;
    vector<int> A[2];
    A[0].reserve(n); A[1].reserve(n);
    for(size_t i = 0; i < n; i++)
    {
        if(p[i] <= l/2) A[0].push_back(p[i]);
        else            A[1].push_back(l - p[i]);
    }
    reverse(A[1].begin(), A[1].end());

    size_t ni = n;
    int64_t result = INT64_MAX, base = 0;
    while(ni)
    {
        int64_t curr = base;
        for(size_t t = 0; t < 2; t++)
            for(size_t i = A[t].size() - 1; i < A[t].size(); i -= k)
                curr += 2 * A[t][i];
        result = min(result, curr);

        for(size_t i = 0; i < k and ni; i++, ni--)
        {
            if(A[0].empty())                    A[1].pop_back();
            else if(A[1].empty())               A[0].pop_back();
            else if(A[0].back() > A[1].back())  A[1].pop_back();
            else                                A[0].pop_back();
        }
        base += l;
    }
    result = min(result, base);

    return result;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 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 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 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 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Incorrect 5 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 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 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Incorrect 5 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 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 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 256 KB Output is correct
15 Incorrect 5 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -