Submission #499357

#TimeUsernameProblemLanguageResultExecution timeMemory
499357SirCovidThe19thSemiexpress (JOI17_semiexpress)C++17
100 / 100
3 ms388 KiB
#include <bits/stdc++.h>
using namespace std; 

#define ll long long

int 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 (dst == 1e18){
            dst = min((t - ti) / a, (pos == n) ? 0 : (*S.upper_bound(pos) - pos - 1));
            if (ti > t){ k--; continue; }
        }
        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 and ti <= t) 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...