#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ' ' << x << '\n'
#define endl '\n'
using namespace std;
const int M = 1e9 + 7;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int N, M, K;
cin >> N >> M >> K;
K -= M;
ll vA, vB, vC;
cin >> vA >> vB >> vC;
ll limit;
cin >> limit;
vector<ll> exprs(M);
for (auto& n: exprs) cin >> n, --n;
priority_queue<piii, vector<piii>, less<piii>> pq;
ll ans = -1;
for (int i = 0; i < M - 1; i++) {
ll tNow = limit - vB * exprs[i];
if (tNow < 0) break;
ans++;
ll nxtA = min(tNow / vA + exprs[i], exprs[i + 1] - 1);
ans += nxtA - exprs[i];
ll xC = (tNow - (nxtA + 1 - exprs[i]) * vC < 0 ? nxtA : nxtA + 1);
ll tC = tNow - (xC - exprs[i]) * vC;
ll possible = min(xC + tC / vA, exprs[i + 1] - 1);
if (possible - nxtA <= 0) continue;
pq.push({possible - nxtA, make_pair(xC, tC)});
}
while (pq.size() && K) {
auto [dx, xt] = pq.top();
auto& [x, t] = xt;
pq.pop();
K--;
ans += dx;
ll nxtExp = *upper_bound(exprs.begin(), exprs.end(), x);
ll nxtA = x + t / vA;
ll xC = (t - (nxtA - x + 1) * vC < 0 ? nxtA : nxtA + 1);
ll tC = t - (xC - x) * vC;
ll possible = min(xC + tC / vA, nxtExp - 1);
if (possible - nxtA == 0) continue;
pq.push({possible - nxtA, make_pair(xC, tC)});
}
if (vB * exprs.back() <= limit) ans++;
cout << ans << '\n';
return 0;
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:51:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
51 | auto [dx, xt] = pq.top();
| ^
semiexpress.cpp:52:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
52 | auto& [x, t] = xt;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 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 |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |