Submission #637233

#TimeUsernameProblemLanguageResultExecution timeMemory
637233nehasaneBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h"
using ll = long long;
long long delivery(int N, int K, int L, int p[]) {
    ll ans = 0;
    sort(positions, positions + N);
    int x = K-1;
    int st = positions[0], ed = positions[0];
    for (int i = 1; i < N; i++) {
        if (x > 0) {
            ll new_grp = 0, old_grp = 0;
            new_grp = min({L, (L - st) * 2, ed * 2}) + min({L, positions[i] * 2, (L - positions[i]) * 2});
            old_grp = min({L, positions[i] * 2, (L - st) * 2});
            if (new_grp <= old_grp) {
                old_grp = min({L, (L - st) * 2, ed * 2});
                ans += old_grp;
                x = K - 1;
                st = ed = positions[i];
            } else {
                x--;
                ed = positions[i];
            }
        } else {
            ll old_grp = min({L, (L - st) * 2, ed * 2});
            ans += old_grp;
            st = ed = positions[i];
            x = K-1;
        }
    }
    ans += min({L, (L - st) * 2, ed * 2});
    return ans;
}

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:5:10: error: 'positions' was not declared in this scope
    5 |     sort(positions, positions + N);
      |          ^~~~~~~~~
boxes.cpp:5:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    5 |     sort(positions, positions + N);
      |     ^~~~
      |     short
boxes.cpp:11:45: error: 'ed' was not declared in this scope
   11 |             new_grp = min({L, (L - st) * 2, ed * 2}) + min({L, positions[i] * 2, (L - positions[i]) * 2});
      |                                             ^~
boxes.cpp:11:23: error: 'min' was not declared in this scope
   11 |             new_grp = min({L, (L - st) * 2, ed * 2}) + min({L, positions[i] * 2, (L - positions[i]) * 2});
      |                       ^~~
boxes.cpp:23:48: error: 'ed' was not declared in this scope
   23 |             ll old_grp = min({L, (L - st) * 2, ed * 2});
      |                                                ^~
boxes.cpp:23:26: error: 'min' was not declared in this scope
   23 |             ll old_grp = min({L, (L - st) * 2, ed * 2});
      |                          ^~~
boxes.cpp:29:34: error: 'ed' was not declared in this scope
   29 |     ans += min({L, (L - st) * 2, ed * 2});
      |                                  ^~
boxes.cpp:29:12: error: 'min' was not declared in this scope
   29 |     ans += min({L, (L - st) * 2, ed * 2});
      |            ^~~
boxes.cpp:3:45: warning: unused parameter 'p' [-Wunused-parameter]
    3 | long long delivery(int N, int K, int L, int p[]) {
      |                                         ~~~~^~~