#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
using ll = long long;
const int N = 1e5 + 24;
int n, m, k, s[N];
ll A, B, C, maxTime;
void solve() {
cin >> n >> m >> k;
cin >> A >> B >> C;
cin >> maxTime;
for (int i = 1; i <= m; i++) {
cin >> s[i];
}
s[m + 1] = n + 1;
ll ans = 0;
multiset<ll> gain;
for (int i = 1; i <= m; i++) {
ll L = s[i], R = s[i + 1] - 1;
for (ll cnt = 0, l = L; l <= R; cnt++) {
ll current = (L - 1) * B + (l - L) * C;
if (current > maxTime) break;
ll r = min(R, (maxTime - current + l * A) / A);
if (r < l) break;
if (cnt == 0) {
ans += r - l + 1;
}
else {
ans += r - l + 1;
gain.insert(r - l + 1);
if (gain.size() > k - m) {
ll bad = *gain.begin();
gain.erase(gain.find(bad));
ans -= bad;
}
}
l = r + 1;
}
}
cout << ans - 1 << '\n';
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int T = 1; // cin >> T;
while (T--) {
solve();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |