Submission #225233

# Submission time Handle Problem Language Result Execution time Memory
225233 2020-04-19T18:31:17 Z PedroBigMan Visiting Singapore (NOI20_visitingsingapore) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF 100000000000000000LL
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll K,N,M,A,B; cin>>K>>N>>M>>A>>B; A=-A; B=-B;
    vector<ll> v; In(v,K);
    vector<ll> s; In(s,N); REP(i,0,N) {s[i]--;}
    vector<ll> t; In(t,M); REP(i,0,M) {t[i]--;}
    if(K==1)
    {
        if(M<=N) {cout<<M*v[0]<<endl;}
        else {cout<<N*v[0]-A-(M-N)*B<<endl;}   
        return 0;
    }
    if(A==0)
    {
        vector<pl> cur; REP(i,0,M) {cur.pb(mp(-INF,-INF));}
        REP(i,0,K) {v[i]+=B;}
        ll ans=0LL;
        REP(i,0,N)
        {
            ll maxv=0LL; ll lastmaxv=0LL;
            REP(j,0,M)
            {
                if(s[i]==t[j])
                {
                    cur[j].ff=max(cur[j].ff-B,cur[j].ss-A-B);
                    if(j==0) {cur[j].ss=max(cur[j].ff-B, max(cur[j].ss-A-B,v[s[i]]-A));}
                    else {cur[j].ss=max(cur[j-1].ss+v[s[i]],max(lastmaxv))}
                }
                else
                {
                    cur[j].ff=max(cur[j].ff-B,cur[j].ss-A-B);
                    cur[j].ss=-INF;
                }
            }
        }
        cout<<ans-M*B<<endl;
    }
    return 0;
}

Compilation message

VisitingSingapore.cpp: In function 'void Out(std::vector<long long int>)':
VisitingSingapore.cpp:14:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
VisitingSingapore.cpp:23:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
VisitingSingapore.cpp:23:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
VisitingSingapore.cpp: In function 'int main()':
VisitingSingapore.cpp:53:73: error: no matching function for call to 'max(ll&)'
                     else {cur[j].ss=max(cur[j-1].ss+v[s[i]],max(lastmaxv))}
                                                                         ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from VisitingSingapore.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:53:73: note:   candidate expects 2 arguments, 1 provided
                     else {cur[j].ss=max(cur[j-1].ss+v[s[i]],max(lastmaxv))}
                                                                         ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from VisitingSingapore.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:53:73: note:   candidate expects 3 arguments, 1 provided
                     else {cur[j].ss=max(cur[j-1].ss+v[s[i]],max(lastmaxv))}
                                                                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from VisitingSingapore.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:53:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                     else {cur[j].ss=max(cur[j-1].ss+v[s[i]],max(lastmaxv))}
                                                                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from VisitingSingapore.cpp:4:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
VisitingSingapore.cpp:53:73: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
                     else {cur[j].ss=max(cur[j-1].ss+v[s[i]],max(lastmaxv))}
                                                                         ^
VisitingSingapore.cpp:46:16: warning: unused variable 'maxv' [-Wunused-variable]
             ll maxv=0LL; ll lastmaxv=0LL;
                ^~~~