# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1125351 | VVUU | 메기 농장 (IOI22_fish) | C++20 | 컴파일 에러 | 0 ms | 0 KiB |
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
long long max_weights(long long n, long long m, vector<int> x, vector<int> y, vector<int> w){
vector<vector<pair<int, int> > > p;
vector<vector<vector<int> > > dp;
vector<vector<int> > pre;
vector<int> ans;
p.resize(n+10);
dp.resize(n+10);
ans.resize(n+10);
for(long long i=0; i<=n; i++) p[i].push_back(make_pair(0, 0));
for(long long i=0; i<m; i++) p[x[i]].push_back(make_pair(y[i], w[i]));
for(long long i=1; i<=n; i++)
for(long long i=1; i<=n; i++)
for(long long i=1; i<=n; i++){
sort(p[i].begin(), p[i].end());
dp[i].resize(p[i].size(), vector<int>(5));
pre[i].resize(p[i].size());
for(long long j=1; j<p[i].size(); j++) pre[i][j]+=pre[i][j-1]+p[i][j].second;
}
for(long long i=2; i<=n; i++){
dp[i][0][0]=dp[i-1][0][0];
long long L=p[i-1].size();
long long val=dp[i-1][L][0]+pre[i].back();
for(long long j=pre[i].size()-1; j>=0; j--){
while(L && p[i-1][L-1].first>p[i][j].first) L--, val=max(val, dp[i-1][L][0]+pre[i][j]);
if(j) dp[i][j][3]=max(dp[i][j][3], val-pre[i][j-1]);
else dp[i][j][3]=max(dp[i][j][3], val);
}
dp[i][0][0]=max(dp[i][0][0], dp[i][0][3]);
long long D=0; val=-1e18;
for(long long j=1; j<p[i].size(); j++){
dp[i][j][1]=dp[i-1][0][0];
while(D+1<p[i-1].size() && p[i-1][D+1].first<p[i][j].first){
D++; val=max(val, dp[i-1][D][2]-pre[i-1][D-1]);
}
dp[i][j][2]=max(dp[i][j][2], max(val, ans[i-2])+pre[i-1][D]);
}
ans[i]=dp[i][0][0];
for(long long j=1; j<p[i].size(); j++){
dp[i][j][0]=max(dp[i][j][1], max(dp[i][j][2], dp[i][j][3]));
ans[i]=max(ans[i], dp[i][j][0]);
}
}
return ans[n];
}
컴파일 시 표준 에러 (stderr) 메시지
fish.cpp: In function 'long long int max_weights(long long int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)': fish.cpp:27:81: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)' 27 | while(L && p[i-1][L-1].first>p[i][j].first) L--, val=max(val, dp[i-1][L][0]+pre[i][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: fish.cpp:27:81: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 27 | while(L && p[i-1][L-1].first>p[i][j].first) L--, val=max(val, dp[i-1][L][0]+pre[i][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: fish.cpp:27:81: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 27 | while(L && p[i-1][L-1].first>p[i][j].first) L--, val=max(val, dp[i-1][L][0]+pre[i][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: fish.cpp:27:81: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | while(L && p[i-1][L-1].first>p[i][j].first) L--, val=max(val, dp[i-1][L][0]+pre[i][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: fish.cpp:27:81: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | while(L && p[i-1][L-1].first>p[i][j].first) L--, val=max(val, dp[i-1][L][0]+pre[i][j]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fish.cpp:28:46: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int)' 28 | if(j) dp[i][j][3]=max(dp[i][j][3], val-pre[i][j-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: fish.cpp:28:46: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 28 | if(j) dp[i][j][3]=max(dp[i][j][3], val-pre[i][j-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: fish.cpp:28:46: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 28 | if(j) dp[i][j][3]=max(dp[i][j][3], val-pre[i][j-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: fish.cpp:28:46: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 28 | if(j) dp[i][j][3]=max(dp[i][j][3], val-pre[i][j-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: fish.cpp:28:46: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 28 | if(j) dp[i][j][3]=max(dp[i][j][3], val-pre[i][j-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fish.cpp:29:45: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, long long int&)' 29 | else dp[i][j][3]=max(dp[i][j][3], val); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: fish.cpp:29:45: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 29 | else dp[i][j][3]=max(dp[i][j][3], val); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: fish.cpp:29:45: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 29 | else dp[i][j][3]=max(dp[i][j][3], val); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: fish.cpp:29:45: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 29 | else dp[i][j][3]=max(dp[i][j][3], val); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: fish.cpp:29:45: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 29 | else dp[i][j][3]=max(dp[i][j][3], val); | ~~~^~~~~~~~~~~~~~~~~~ fish.cpp:36:45: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)' 36 | D++; val=max(val, dp[i-1][D][2]-pre[i-1][D-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: fish.cpp:36:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 36 | D++; val=max(val, dp[i-1][D][2]-pre[i-1][D-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: fish.cpp:36:45: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 36 | D++; val=max(val, dp[i-1][D][2]-pre[i-1][D-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: fish.cpp:36:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 36 | D++; val=max(val, dp[i-1][D][2]-pre[i-1][D-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: fish.cpp:36:45: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 36 | D++; val=max(val, dp[i-1][D][2]-pre[i-1][D-1]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fish.cpp:38:57: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 38 | dp[i][j][2]=max(dp[i][j][2], max(val, ans[i-2])+pre[i-1][D]); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: fish.cpp:38:57: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 38 | dp[i][j][2]=max(dp[i][j][2], max(val, ans[i-2])+pre[i-1][D]); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:60, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: fish.cpp:38:57: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 38 | dp[i][j][2]=max(dp[i][j][2], max(val, ans[i-2])+pre[i-1][D]); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)' 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: fish.cpp:38:57: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 38 | dp[i][j][2]=max(dp[i][j][2], max(val, ans[i-2])+pre[i-1][D]); | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/vector:62, from fish.h:1, from fish.cpp:1: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)' 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: fish.cpp:38:57: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 38 | dp[i][j][2]=max(dp[i][j][2], max(val, ans[i-2])+pre[i-1][D]); | ~~~^~~~~~~~~~~~~~~