제출 #637231

#제출 시각아이디문제언어결과실행 시간메모리
637231nehasaneBoxes with souvenirs (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h"

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;
}

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:4:5: error: 'll' was not declared in this scope
    4 |     ll ans = 0;
      |     ^~
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:10:15: error: expected ';' before 'new_grp'
   10 |             ll new_grp = 0, old_grp = 0;
      |               ^~~~~~~~
      |               ;
boxes.cpp:11:13: error: 'new_grp' 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: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:12:13: error: 'old_grp' was not declared in this scope
   12 |             old_grp = min({L, positions[i] * 2, (L - st) * 2});
      |             ^~~~~~~
boxes.cpp:15:17: error: 'ans' was not declared in this scope
   15 |                 ans += old_grp;
      |                 ^~~
boxes.cpp:23:15: error: expected ';' before 'old_grp'
   23 |             ll old_grp = min({L, (L - st) * 2, ed * 2});
      |               ^~~~~~~~
      |               ;
boxes.cpp:23:55: error: expected primary-expression before ')' token
   23 |             ll old_grp = min({L, (L - st) * 2, ed * 2});
      |                                                       ^
boxes.cpp:24:13: error: 'ans' was not declared in this scope
   24 |             ans += old_grp;
      |             ^~~
boxes.cpp:24:20: error: 'old_grp' was not declared in this scope
   24 |             ans += old_grp;
      |                    ^~~~~~~
boxes.cpp:25:18: error: 'ed' was not declared in this scope
   25 |             st = ed = positions[i];
      |                  ^~
boxes.cpp:29:5: error: 'ans' was not declared in this scope
   29 |     ans += 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[]) {
      |                                         ~~~~^~~