# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680186 | fdnfksd | Visiting Singapore (NOI20_visitingsingapore) | C++14 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=int;
const ll maxN=5005;
const ll inf=2e9;
ll mn[5005][5005],mn2[5005][5005],mn1[5005][5005];
void update(ll i,ll j,ll val)
{
mn1[i][j]=max(mn1[i][j-1],val);
mn2[i][j]=max(mn2[i-1][j],val);
mn[i][j]=max({mn[i-1][j],mn[i][j-1],val});
}
ll k,n,m,a,b,s[maxN],v[101],t[maxN];
long long dp[5005][5005];
void solve()
{
cin >> k >> n >> m >> a >> b;
for(int i=1;i<=k;i++) cin >> v[i];
for(int i=1;i<=n;i++) cin >> s[i];
for(int i=1;i<=m;i++) cin >> t[i];
mn[0][0]=mn1[0][0]=mn2[0][0]=-inf;
for(int i=1;i<=n;i++)
{
mn[i][0]=mn[0][i]=mn1[i][0]=mn1[0][i]=mn2[0][i]=mn2[i][0]=-inf;
}
dp[0][0]=0;
ll ans=-inf;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(s[i]==t[j])
{
dp[i][j]=v[s[i]]+(a*(j>1)+b*(j-1));
ll x;
x=mn1[i-1][j-1];
dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]);
x=mn2[i-1][j-1];
dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]);
if(i>=2&&j>=2)
{
x=mn[i-2][j-2];
dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+2*a+v[s[i]]);
}
if(i>1&&j>1) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+v[s[i]]);
}
else
{
dp[i][j]=-inf;
}
update(i,j,dp[i][j]-b*i-b*j);
ans=max(ans,dp[i][j]+(a*(m>j)+b*(m-j)));
}
}
cout << ans;
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
solve();
}
Compilation message (stderr)
VisitingSingapore.cpp: In function 'void solve()': VisitingSingapore.cpp:41:62: error: no matching function for call to 'max(long long int&, ll)' 41 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:41:62: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'int'}) 41 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:41:62: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'int'}) 41 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:41:62: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:41:62: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ VisitingSingapore.cpp:43:62: error: no matching function for call to 'max(long long int&, ll)' 43 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:43:62: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'int'}) 43 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:43:62: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'int'}) 43 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:43:62: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 43 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:43:62: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 43 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+a+v[s[i]]); | ^ VisitingSingapore.cpp:47:68: error: no matching function for call to 'max(long long int&, ll)' 47 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+2*a+v[s[i]]); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:47:68: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'int'}) 47 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+2*a+v[s[i]]); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:47:68: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'll' {aka 'int'}) 47 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+2*a+v[s[i]]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:47:68: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 47 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+2*a+v[s[i]]); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:47:68: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 47 | dp[i][j]=max(dp[i][j],x+i*b+j*b-2*b+2*a+v[s[i]]); | ^ VisitingSingapore.cpp:56:51: error: no matching function for call to 'max(ll&, long long int)' 56 | ans=max(ans,dp[i][j]+(a*(m>j)+b*(m-j))); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:56:51: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 56 | ans=max(ans,dp[i][j]+(a*(m>j)+b*(m-j))); | ^ 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 VisitingSingapore.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: VisitingSingapore.cpp:56:51: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 56 | ans=max(ans,dp[i][j]+(a*(m>j)+b*(m-j))); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:56:51: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 56 | ans=max(ans,dp[i][j]+(a*(m>j)+b*(m-j))); | ^ In file included from /usr/include/c++/10/algorithm:62, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65, from VisitingSingapore.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: VisitingSingapore.cpp:56:51: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 56 | ans=max(ans,dp[i][j]+(a*(m>j)+b*(m-j))); | ^