Submission #33324

#TimeUsernameProblemLanguageResultExecution timeMemory
33324minhtung0404Semiexpress (JOI17_semiexpress)C++14
100 / 100
0 ms2212 KiB
#include<bits/stdc++.h> const long long N = 3005; using namespace std; typedef pair <long long, long long> ii; typedef pair <ii, long long> iii; priority_queue <iii> mq; long long n, m, k, a, b, c, s[N], ans, T; long long cal(long long pos, long long pre){ long long val = T - (s[pre]-1)*b - (pos-s[pre])*c; if (val < 0) return 0; return 1 + val/a; } int main(){ cin >> n >> m >> k >> a >> b >> c >> T; k-=m; for (long long i = 1; i <= m; i++) cin >> s[i]; if ((n-1)*b > T) ans = -1; for (long long i = 1; i < m; i++){ long long pos = s[i], pre = i, val = cal(pos, pre); if (pos + val > s[pre+1]) val = s[pre+1]-pos; ans += val; pos += val; if (pos == s[pre+1]) continue; val = cal(pos, pre); if (pos + val > s[pre+1]) val = s[pre+1]-pos; mq.push(iii(ii(val, pos), pre)); } for (long long i = 1; i <= k && mq.size(); i++){ iii z = mq.top(); mq.pop(); long long pos = z.first.second, val = z.first.first, pre = z.second; ans += val; pos += val; if (pos == s[pre+1]) continue; val = cal(pos, pre); if (pos + val > s[pre+1]) val = s[pre+1] - pos; mq.push(iii(ii(val, pos), pre)); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...