/*
author: lunchbox
problem link: https://oj.uz/problem/view/JOI17_semiexpress
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n, m, k; cin >> n >> m >> k;
LL a, b, c; cin >> a >> b >> c;
long long t; cin >> t;
vector<LL> s(m), p(m - 1); for (LL& x : s) cin >> x;
priority_queue<pair<LL, int>> pq;
LL ans = 0;
for (int i = 0; i < m - 1; i++) {
if (b * (s[i] - 1) > t) {
cout << "?\n";
continue;
}
LL u = min(s[i + 1] - 1, s[i] + (t - b * (s[i] - 1)) / a);
ans += u - s[i] + 1;
p[i] = u + 1;
if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t) {
LL v = min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a);
pq.push({v - p[i] + 1, i});
}
}
for (int it = 0; it < k - m; it++) {
if (pq.empty()) break;
auto [v, i] = pq.top(); pq.pop();
ans += v, p[i] += v;
if (p[i] < s[i + 1] && b * (s[i] - 1) + c * (p[i] - s[i]) <= t) {
LL v = min(s[i + 1] - 1, p[i] + (t - b * (s[i] - 1) - c * (p[i] - s[i])) / a);
pq.push({v - p[i] + 1, i});
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |