제출 #128306

#제출 시각아이디문제언어결과실행 시간메모리
128306zeyad49선물상자 (IOI15_boxes)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N=1000; const long long INF=(long)1e18; long long K,L; int memo[N][N]; int teams[N]; long long dist[N][N]; long long dp(int l,int r) { if(l>r) return 0; if(memo[l][r]!=-1) return memo[l][r]; long long ans=INF; if(r-l+1<=K) ans=L; for(int k=l;k<=r;k++){ if(k-l+1>K) break; ans=min(ans,teams[k]+dp(k+1,r)+min(teams[k],L-teams[k])); } for(int k=r;k>=l;k--){ if(r-k+1>K) break; ans=min(ans,L-teams[k]+dp(l,k-1)+min(L-teams[k],teams[k])); } return memo[l][r]=ans; } long long delivery(int a, int b, int c, int x[]) { K=b; L=c; sort(x,x+a); for(int i=0;i<a;i++){ teams[i]=x[i]; for(int j=0;j<a;j++) memo[i][j]=-1; } return dp(0,a-1); }

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

boxes.cpp: In function 'long long int dp(int, int)':
boxes.cpp:19:61: error: no matching function for call to 'min(int&, long long int)'
       ans=min(ans,teams[k]+dp(k+1,r)+min(teams[k],L-teams[k]));
                                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:61: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
       ans=min(ans,teams[k]+dp(k+1,r)+min(teams[k],L-teams[k]));
                                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:61: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
       ans=min(ans,teams[k]+dp(k+1,r)+min(teams[k],L-teams[k]));
                                                             ^
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:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:61: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
       ans=min(ans,teams[k]+dp(k+1,r)+min(teams[k],L-teams[k]));
                                                             ^
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:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:19:61: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
       ans=min(ans,teams[k]+dp(k+1,r)+min(teams[k],L-teams[k]));
                                                             ^
boxes.cpp:24:63: error: no matching function for call to 'min(long long int, int&)'
       ans=min(ans,L-teams[k]+dp(l,k-1)+min(L-teams[k],teams[k]));
                                                               ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
boxes.cpp:24:63: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
       ans=min(ans,L-teams[k]+dp(l,k-1)+min(L-teams[k],teams[k]));
                                                               ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from boxes.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
boxes.cpp:24:63: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
       ans=min(ans,L-teams[k]+dp(l,k-1)+min(L-teams[k],teams[k]));
                                                               ^
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:1:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
boxes.cpp:24:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
       ans=min(ans,L-teams[k]+dp(l,k-1)+min(L-teams[k],teams[k]));
                                                               ^
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:1:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
boxes.cpp:24:63: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
       ans=min(ans,L-teams[k]+dp(l,k-1)+min(L-teams[k],teams[k]));
                                                               ^
boxes.cpp:26:21: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   return memo[l][r]=ans;
                     ^~~