제출 #1033514

#제출 시각아이디문제언어결과실행 시간메모리
1033514warrennCloud Computing (CEOI18_clo)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; bool cmp(tuple<int,int,int,int>q,tuple<int,int,int,int>w ){ auto &[a,b,c,type]=q; auto &[d,e,f,tipe]=w; if(b!=e){ return b<e; } else{ return type>tipe; } } int main(){ int n; cin>>n; vector<tuple<int,int,int,int> > barang; int sum=0; for(int q=1;q<=n;q++){ int a,b,c; cin>>a>>b>>c; barang.push_back({a,b,c,0}); sum+=b; } int m; cin>>m; for(int q=1;q<=m;q++){ int a,b,c; cin>>a>>b>>c; barang.push_back({a,b,c,1}); } sort(barang.begin(),barang.end(),cmp); long long dp[2][sum+2]; for(int q=0;q<=1;q++){ for(int w=0;w<=sum;w++){ dp[q][w]=-1e15; } } dp[(n+m+1)%2][0]=0; for(int q=n+m;q>=1;q--){ for(int w=0;w<=sum;w++){ auto [a,b,c,tipe]=barang[q-1]; dp[q%2][w]=dp[(q+1)%2][w]; if(tipe==0){ if(w-a>=0){ dp[q%2][w]=max(dp[q%2][w],dp[(q+1)%2][w-a]-c); } } else{ if(w+a<=sum){ dp[q%2][w]=max(dp[q%2][w],dp[(q+1)%2][w+a]+c); } } } } int ans=0; for(int q=0;q<=sum;q++){ ans=max(ans,dp[1][q]); } cout<<ans<<endl; }

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

clo.cpp: In function 'int main()':
clo.cpp:61:29: error: no matching function for call to 'max(int&, long long int&)'
   61 |         ans=max(ans,dp[1][q]);
      |                             ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from clo.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
clo.cpp:61:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   61 |         ans=max(ans,dp[1][q]);
      |                             ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from clo.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
clo.cpp:61:29: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   61 |         ans=max(ans,dp[1][q]);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from clo.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
clo.cpp:61:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |         ans=max(ans,dp[1][q]);
      |                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from clo.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
clo.cpp:61:29: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   61 |         ans=max(ans,dp[1][q]);
      |                             ^