#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n, m, k;
cin >> n >> m >> k;
ll a, b, c;
cin >> a >> b >> c; //slow, fast, middle
ll t;
cin >> t;
vector<ll> s(m);
for (int i = 0; i < m; ++i) {
cin >> s[i];
}
vector<pair<ll, bool>> v;
ll ans = 0;
s.push_back(n + 1);
for (int i = 0; i <= m; ++i) {
ll dist = (s[i] - 1) * b;
if (dist > t) {
break;
}
ll x = s[i];
int cnt = 0;
while (x < s[i + 1] && dist <= t && cnt < k) {
ll nxt = (t - dist) / a;
if (x + nxt + 1 >= s[i + 1]) {
nxt = s[i + 1] - x - 1;
}
cnt += (x != s[i]);
v.push_back({nxt + 1, x != s[i]});
dist += (nxt + 1) * c;
x += nxt + 1;
}
}
sort(v.begin(), v.end(), greater());
int cnt = m;
for (int i = 0; i < v.size(); ++i) {
if (cnt + v[i].second <= k) {
ans += v[i].first;
cnt += v[i].second;
}
}
cout << ans - 1;
return 0;
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:43:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for (int i = 0; i < v.size(); ++i) {
| ~~^~~~~~~~~~
# |
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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
256 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 |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
256 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 |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
7 ms |
4560 KB |
Output is correct |
22 |
Correct |
5 ms |
2516 KB |
Output is correct |
23 |
Correct |
31 ms |
16904 KB |
Output is correct |
24 |
Correct |
30 ms |
8652 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
91 ms |
33336 KB |
Output is correct |
28 |
Correct |
147 ms |
66148 KB |
Output is correct |
29 |
Correct |
23 ms |
8596 KB |
Output is correct |
30 |
Correct |
8 ms |
4552 KB |
Output is correct |