Submission #499353

#TimeUsernameProblemLanguageResultExecution timeMemory
499353SirCovidThe19thSemiexpress (JOI17_semiexpress)C++17
48 / 100
2 ms392 KiB
#include <bits/stdc++.h>
using namespace std; 

#define ll long long
#define int ll

signed main(){
    int n, m, k; ll a, b, c, t, ans = 0;
    cin >> n >> m >> k >> a >> b >> c >> t;

    set<ll> S; priority_queue<tuple<ll, ll, ll>> pq;
    
    for (int i = 1; i <= m; i++){
        ll pos; cin >> pos;
        S.insert(pos); pq.push({1e18, (pos - 1) * b, pos});
    }
    while (!pq.empty() and k){
        ll dst, ti, pos; tie(dst, ti, pos) = pq.top(); pq.pop();
        if (ti > t) continue;

        if (dst == 1e18) dst = min((t - ti) / a, (pos == n) ? 0 : *S.upper_bound(pos) - pos - 1);
        ans += dst + 1; k--;

        pos += dst + 1; ti += (dst + 1) * c;
        dst = min((t - ti) / a, *S.lower_bound(pos) - pos - 1);
        if (dst >= 0) pq.push({dst, ti, pos});
    }
    cout<<ans - 1<<endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...