#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve() {
int N, M, K;
cin >> N >> M >> K;
int A, B, C;
cin >> A >> B >> C;
long long T;
cin >> T;
vector<int> S(M);
for (auto &v : S) {
cin >> v;
v--;
}
set<tuple<long long, int, int>> s;
long long ans = -1;
auto Place = [&](long long time, int position, int j) {
long long pos = position + (T - time) / A + 1;
bool bad = false;
if (pos >= N) {
pos = N;
bad = true;
}
if (j + 1 < M && S[j + 1] <= pos) {
pos = S[j + 1];
bad = true;
}
ans += pos - position;
if (!bad) {
s.emplace(1ll * S[j] * B + 1ll * (pos - S[j]) * C, pos, j);
}
};
for (int i = 0; i < M; i++) {
long long time = 1ll * S[i] * B;
int position = S[i];
int j = i;
if (time <= T) {
Place(time, position, j);
}
}
for (int i = 0; i < K - M && !s.empty(); i++) {
auto [time, position, j] = *s.begin();
s.erase(s.begin());
if (time > T) {
break;
}
Place(time, position, j);
}
cout << ans << "\n";
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |