This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |