제출 #813149

#제출 시각아이디문제언어결과실행 시간메모리
813149OrazB선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> // #include "boxes.h" using namespace std; #define all(x) (x).begin(), (x).end() #define ll long long int #define pii pair <int, int> #define pb push_back #define ff first #define ss second // const int N = 1e5+5; ll delivery(int n, int K, int L, int p[]){ if (K == 1){ ll sum = 0; for (int i = 0; i < n; i++){ sum += min(p[i], L-p[i])*2; } return sum; } int j = -1; for (int i = 0; i < n; i++){ if (L-p[i] >= p[i]) j = i; } if (j == -1 or j == n-1) return n; ll a = p[j]*2, b = (L-p[j+1])*2; return min(n, a+b); } // int main () // { // ios::sync_with_stdio(false); // cin.tie(0); // cin >> t; // while (t--){ // } // }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:27:19: error: no matching function for call to 'min(int&, long long int)'
   27 |  return min(n, a+b);
      |                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:27:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   27 |  return min(n, a+b);
      |                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:27:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   27 |  return min(n, a+b);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:27:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |  return min(n, a+b);
      |                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
boxes.cpp:27:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |  return min(n, a+b);
      |                   ^