Submission #991725

# Submission time Handle Problem Language Result Execution time Memory
991725 2024-06-03T00:59:55 Z irmuun Semiexpress (JOI17_semiexpress) C++17
18 / 100
66 ms 348 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,m,k;
    cin>>n>>m>>k;
    ll a,b,c;
    cin>>a>>b>>c;
    ll t;
    cin>>t;
    ll s[m+5];
    vector<bool>used(n+5,0);
    for(ll i=1;i<=m;i++){
        cin>>s[i];
        used[s[i]]=true;
    }
    vector<ll>v;
    for(ll i=1;i<=n;i++){
        if(!used[i]){
            v.pb(i);
        }
    }
    vector<pair<ll,ll>>bef[n+5];
    for(ll i=2;i<=n;i++){
        bef[i].pb({i-1,0});
    }
    for(ll i=1;i<m;i++){
        bef[s[i+1]].pb({s[i],1});
    }
    ll dp[n+5],ans=0;
    for(ll i=0;i<v.size();i++){
        for(ll j=i+1;j<v.size();j++){
            ll last=0;
            for(ll l=1;l<=n;l++){
                if(used[l]||l==v[i]||l==v[j]){
                    if(last>0) bef[l].pb({last,2});
                    last=l;
                }
            }
            dp[1]=0;
            ll cur=0;
            for(ll l=2;l<=n;l++){
                dp[l]=1e18;
                for(auto [x,y]:bef[l]){
                    if(y==0) dp[l]=min(dp[l],dp[x]+(l-x)*a);
                    if(y==1) dp[l]=min(dp[l],dp[x]+(l-x)*b);
                    if(y==2) dp[l]=min(dp[l],dp[x]+(l-x)*c);
                }
                if(dp[l]<=t){
                    cur++;
                }
            }
            ans=max(ans,cur);
            last=0;
            for(ll l=1;l<=n;l++){
                if(used[l]||l==v[i]||l==v[j]){
                    if(last>0) bef[l].pop_back();
                    last=l;
                }
            }
        }
    }
    cout<<ans;
}

Compilation message

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:40:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(ll i=0;i<v.size();i++){
      |                ~^~~~~~~~~
semiexpress.cpp:41:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(ll j=i+1;j<v.size();j++){
      |                      ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 62 ms 348 KB Output is correct
2 Correct 65 ms 348 KB Output is correct
3 Correct 47 ms 344 KB Output is correct
4 Correct 61 ms 348 KB Output is correct
5 Correct 63 ms 344 KB Output is correct
6 Correct 60 ms 344 KB Output is correct
7 Correct 62 ms 348 KB Output is correct
8 Correct 66 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 348 KB Output is correct
2 Correct 65 ms 348 KB Output is correct
3 Correct 47 ms 344 KB Output is correct
4 Correct 61 ms 348 KB Output is correct
5 Correct 63 ms 344 KB Output is correct
6 Correct 60 ms 344 KB Output is correct
7 Correct 62 ms 348 KB Output is correct
8 Correct 66 ms 348 KB Output is correct
9 Correct 61 ms 348 KB Output is correct
10 Correct 60 ms 344 KB Output is correct
11 Incorrect 65 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 348 KB Output is correct
2 Correct 65 ms 348 KB Output is correct
3 Correct 47 ms 344 KB Output is correct
4 Correct 61 ms 348 KB Output is correct
5 Correct 63 ms 344 KB Output is correct
6 Correct 60 ms 344 KB Output is correct
7 Correct 62 ms 348 KB Output is correct
8 Correct 66 ms 348 KB Output is correct
9 Correct 61 ms 348 KB Output is correct
10 Correct 60 ms 344 KB Output is correct
11 Incorrect 65 ms 348 KB Output isn't correct
12 Halted 0 ms 0 KB -