답안 #115362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
115362 2019-06-07T02:55:14 Z socho 선물상자 (IOI15_boxes) C++14
컴파일 오류
0 ms 0 KB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;

long long delivery(int N, int K, int L, int p[]) {
    if (K == 1) {
        long long sm = 0;
        for (int i=0; i<N; i++) {
            long long res = min(p[i], L-p[i]);
            sm += res;
        }
        return sm * 2;
    }
    if (K == N) {
        long long lr = L;
        long long mx = p[N-1];
        long long mn = p[0];
        long long goingMn = mx * 2;
        long long goingMx = (L-mn)*2;
        long long alt = 0;
        long long mxr = 0;
        long long mxl = 0;
        for (int i=0; i<N; i++) {
            if (p[i] * 2 < L) {
                mxl = max(mxl, p[i]);
            }
            else {
                mxr = max(mxr, L-p[i]);
            }
        }
        alt = (mxr + mxl) * 2;
        return min(min(alt, lr), min(goingMn, goingMx));
    }
    return 0;
}

Compilation message

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:25:36: error: no matching function for call to 'max(long long int&, int&)'
                 mxl = max(mxl, p[i]);
                                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                 mxl = max(mxl, p[i]);
                                    ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:36: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                 mxl = max(mxl, p[i]);
                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 mxl = max(mxl, p[i]);
                                    ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:25:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 mxl = max(mxl, p[i]);
                                    ^
boxes.cpp:28:38: error: no matching function for call to 'max(long long int&, int)'
                 mxr = max(mxr, L-p[i]);
                                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
boxes.cpp:28:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                 mxr = max(mxr, L-p[i]);
                                      ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
boxes.cpp:28:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
                 mxr = max(mxr, L-p[i]);
                                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
boxes.cpp:28:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 mxr = max(mxr, L-p[i]);
                                      ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:28:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                 mxr = max(mxr, L-p[i]);
                                      ^