Submission #225235

# Submission time Handle Problem Language Result Execution time Memory
225235 2020-04-19T18:35:01 Z PedroBigMan Visiting Singapore (NOI20_visitingsingapore) C++14
10 / 100
9 ms 512 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]],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:46:16: warning: unused variable 'maxv' [-Wunused-variable]
             ll maxv=0LL; ll lastmaxv=0LL;
                ^~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Incorrect 9 ms 512 KB Output isn't correct
22 Halted 0 ms 0 KB -