#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
const int N = 3e3 + 10;
ll s[N];
ll n, m, k;
ll a, b, c;
ll t;
ll prev(ll x) {
int i = upper_bound(s + 1, s + m + 1, x) - s;
return s[i - 1];
}
ll nx(ll x) {
int i = lower_bound(s + 1, s + m + 1, x) - s;
return s[i];
}
int main() {
cin >> n >> m >> k >> a >> b >> c >> t;
for (int i = 1; i <= m; i++) {
cin >> s[i];
}
ll ans = 0;
if ((n - 1) * b <= t) ans++;
priority_queue <pair<ll, ll>> Q;
for (int i = 1; i < m; i++) {
if ((s[i] - 1) * b > t) continue;
if ((s[i] - 1) * b + (s[i + 1] - s[i] - 1) * a <= t) {
ans += (s[i + 1] - s[i]);
continue;
}
ll mnac = t - (s[i] - 1) * b;
ans += (mnac / a) + 1;
ll pos = s[i] + (mnac / a) + 1;
mnac -= (pos - s[i]) * c;
if (mnac >= 0) {
ll u = min(s[i + 1] - pos, (mnac / a) + 1);
Q.push({ u, pos });
}
}
int i = k - m;
while (i-- && !Q.empty()) {
pair <ll, ll> v = Q.top(); Q.pop();
//cout << "? " << v.first << " " << v.second << "\n";
ans += v.first;
if (v.second == -1) continue;
ll prv = prev(v.second);
ll nxt = nx(v.second);
ll u = (v.second - prv) * c + (prv - 1) * b;
ll mnac = t - u;
ll pos = min(nxt, v.second + (mnac / a) + 1);
mnac -= (pos - v.second) * c;
if (mnac >= 0) {
ll z = min(nxt - pos, (mnac / a) + 1);
if (pos >= nxt) pos = -1;
Q.push({ z, pos });
}
}
cout << ans - 1 << "\n";
}
/*
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
420 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
420 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
432 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |