답안 #314212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314212 2020-10-19T05:49:14 Z Karliver 선물상자 (IOI15_boxes) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "boxes.h"


long long delivery(int N, int K, int L, int p[]) {
    long long ans = 0;
    int cur_pos = 0;
    
    int q = K;
    for(int i = 0;i < N;++i) {
        if(K == 0) {
            K = q;
            ans += min(cur_pos, L - cur_pos);
            cur_pos = 0;
        }
        ans += min(abs(p[i] - cur_pos), L - abs(p[i] - cur_pos));

        cur_pos = p[i];
        --K;
    }
    ans += min(cur_pos, L - cur_pos);
    return ans;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:13:20: error: 'min' was not declared in this scope; did you mean 'std::min'?
   13 |             ans += min(cur_pos, L - cur_pos);
      |                    ^~~
      |                    std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
boxes.cpp:16:16: error: 'min' was not declared in this scope; did you mean 'std::min'?
   16 |         ans += min(abs(p[i] - cur_pos), L - abs(p[i] - cur_pos));
      |                ^~~
      |                std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
boxes.cpp:21:12: error: 'min' was not declared in this scope; did you mean 'std::min'?
   21 |     ans += min(cur_pos, L - cur_pos);
      |            ^~~
      |            std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~