제출 #1098871

#제출 시각아이디문제언어결과실행 시간메모리
1098871alexander_707070선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "boxes.h" #define MAXN 200007 using namespace std; const long long inf=1e17; int n,k,L; int team[MAXN]; long long dp[MAXN]; long long cost(int l,int r){ long long a=min(team[l],L-team[r]); long long c=team[r]-team[l]; return min(2*(a+c),L); } long long delivery(int N, int K, int LL,int p[]) { n=N; k=K; L=LL; for(int i=1;i<=n;i++){ team[i]=p[i-1]; } sort(team+1,team+n+1); for(int i=1;i<=n;i++){ dp[i]=inf; for(int f=i;f>=i-k+1;f--){ dp[i]=min(dp[i],dp[f-1]+cost(f,i)); } } if(n<=k)dp[n]=min(dp[n],L); return dp[n]; } /*int main(){ cout<<delivery(3,2,8,{1,2,5})<<"\n"; return 0; }*/

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

boxes.cpp: In function 'long long int cost(int, int)':
boxes.cpp:17:25: error: no matching function for call to 'min(long long int, int&)'
   17 |     return min(2*(a+c),L);
      |                         ^
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:17:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   17 |     return min(2*(a+c),L);
      |                         ^
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:17:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   17 |     return min(2*(a+c),L);
      |                         ^
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:17:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   17 |     return min(2*(a+c),L);
      |                         ^
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:17:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   17 |     return min(2*(a+c),L);
      |                         ^
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:36:30: error: no matching function for call to 'min(long long int&, int&)'
   36 |     if(n<=k)dp[n]=min(dp[n],L);
      |                              ^
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:36:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |     if(n<=k)dp[n]=min(dp[n],L);
      |                              ^
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:36:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   36 |     if(n<=k)dp[n]=min(dp[n],L);
      |                              ^
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:36:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |     if(n<=k)dp[n]=min(dp[n],L);
      |                              ^
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:36:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   36 |     if(n<=k)dp[n]=min(dp[n],L);
      |                              ^