Submission #692030

#TimeUsernameProblemLanguageResultExecution timeMemory
692030Cookie197Semiexpress (JOI17_semiexpress)C++17
100 / 100
12 ms9608 KiB
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define endl "\n"
#define out(x) cout<< #x << " = " << x << endl
#define mp make_pair
#define mt(a,b,c,d) mp(mp(a,b),mp(c,d)) 

ll n,m,k;
ll a,b,c,t,arr[3005],ans;
vector<ll> v[3005];
signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>m>>k>>a>>b>>c>>t;
    for (int i=1;i<=m;i++) cin>>arr[i];
    
    if (b * arr[m] - b <= t) ans++;
    for (int i=1;i<m;i++){
        ll bt = b * (arr[i] - 1);
        if (bt > t) break;
        ll okstations = min((t-bt)/a + 1, arr[i+1] - arr[i]);
        ans += okstations; 
        if (okstations == (arr[i+1] - arr[i])) continue;
        

        ll nowstation = arr[i] + okstations;
        bt += okstations * c;
        for (int j=1;j<=k-m;j++){
            if (bt > t) break;
            okstations = min((t-bt)/a + 1, arr[i+1] - nowstation);
            v[i].push_back(okstations);
            if (okstations == (arr[i+1] - nowstation)) break;

            nowstation += okstations;
            bt += okstations * c;
        }
    }
    

    priority_queue<ll,vector<ll> > pq;
    for (int i=1;i<m;i++){
        //cout<<i<<" : ";
        for (ll u:v[i]) pq.push(u);//, cout<<u<<" ";
        //cout<<endl;
    }
    
    for (int i=1;i<=k-m;i++) if (pq.size()) ans += pq.top(),pq.pop();
    cout<<ans-1<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...