#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i<=b ; i++)
#define FORD(i, a, b) for (int i = a; i>=b; i--)
#define REP(i, a) for (int i = 0; i<a; i++)
#define N 100100
#define pp pair<int, int>
#define IO cin.tie(NULL);cout.tie(NULL);
template<typename T> inline void read(T &x) {
char c;
bool neg = false;
while (!isdigit(c = getchar()) && c != '-');
x = 0;
if (c == '-') {
neg = true;
c = getchar();
}
do {
x = x * 10 + c - '0';
} while (isdigit(c = getchar()));
if (neg) x = -x;
}
template<typename T> inline void write(T x) {
if (x < 0) {
putchar('-');
write(-x);
return;
}
if (x < 10) {
putchar(char(x + 48));
}
else {
write(x/10);
putchar(char(48 + x%10));
}
}
template<typename T> inline void writeln(T x) {
write(x);
putchar('\n');
}
using namespace std;
int n, m, k, s[N];
long long t, b, a, c;
priority_queue<int> heap;
int main() {
IO;
read(n);read(m);read(k);
read(a);read(b);read(c);
read(t);
FOR(i, 1, m) read(s[i]);
int ans = 0, used = 0;
k -= m;
FOR(i, 1, m - 1) {
long long newT = t - (s[i] - 1) * b;
if (newT < 0) break;
int now = s[i];
if ((newT - c * (now - s[i])) / a >= s[i + 1] - s[i] - 1) {
ans += s[i + 1] - s[i];
continue;
}
int cnt = 0;
while (true) {
if (cnt == k) break;
if (newT - c * (now - s[i]) < 0) break;
if (now + (newT - c * (now - s[i])) / a >= s[i + 1]) {
heap.push(s[i + 1] - now);
break;
}
if (now != s[i]) {
cnt++;
heap.push((newT - c * (now - s[i])) / a + 1);
} else ans += (newT - c * (now - s[i])) / a + 1;
now = now + (newT - c * (now - s[i])) / a + 1;
}
}
if (b * (n - 1) <= t) ans++;
while (used < k && !heap.empty()) {
ans += heap.top();
heap.pop();
used++;
}
writeln(ans - 1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2404 KB |
Output is correct |
2 |
Correct |
0 ms |
2404 KB |
Output is correct |
3 |
Correct |
0 ms |
2404 KB |
Output is correct |
4 |
Correct |
0 ms |
2404 KB |
Output is correct |
5 |
Correct |
0 ms |
2404 KB |
Output is correct |
6 |
Correct |
0 ms |
2404 KB |
Output is correct |
7 |
Correct |
0 ms |
2404 KB |
Output is correct |
8 |
Correct |
0 ms |
2404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2404 KB |
Output is correct |
2 |
Correct |
0 ms |
2404 KB |
Output is correct |
3 |
Correct |
0 ms |
2404 KB |
Output is correct |
4 |
Correct |
0 ms |
2404 KB |
Output is correct |
5 |
Correct |
0 ms |
2404 KB |
Output is correct |
6 |
Correct |
0 ms |
2404 KB |
Output is correct |
7 |
Correct |
0 ms |
2404 KB |
Output is correct |
8 |
Correct |
0 ms |
2404 KB |
Output is correct |
9 |
Correct |
0 ms |
2404 KB |
Output is correct |
10 |
Correct |
0 ms |
2404 KB |
Output is correct |
11 |
Correct |
0 ms |
2404 KB |
Output is correct |
12 |
Correct |
0 ms |
2404 KB |
Output is correct |
13 |
Correct |
0 ms |
2404 KB |
Output is correct |
14 |
Correct |
0 ms |
2404 KB |
Output is correct |
15 |
Correct |
0 ms |
2404 KB |
Output is correct |
16 |
Correct |
0 ms |
2404 KB |
Output is correct |
17 |
Correct |
0 ms |
2404 KB |
Output is correct |
18 |
Correct |
0 ms |
2404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2404 KB |
Output is correct |
2 |
Correct |
0 ms |
2404 KB |
Output is correct |
3 |
Correct |
0 ms |
2404 KB |
Output is correct |
4 |
Correct |
0 ms |
2404 KB |
Output is correct |
5 |
Correct |
0 ms |
2404 KB |
Output is correct |
6 |
Correct |
0 ms |
2404 KB |
Output is correct |
7 |
Correct |
0 ms |
2404 KB |
Output is correct |
8 |
Correct |
0 ms |
2404 KB |
Output is correct |
9 |
Correct |
0 ms |
2404 KB |
Output is correct |
10 |
Correct |
0 ms |
2404 KB |
Output is correct |
11 |
Correct |
0 ms |
2404 KB |
Output is correct |
12 |
Correct |
0 ms |
2404 KB |
Output is correct |
13 |
Correct |
0 ms |
2404 KB |
Output is correct |
14 |
Correct |
0 ms |
2404 KB |
Output is correct |
15 |
Correct |
0 ms |
2404 KB |
Output is correct |
16 |
Correct |
0 ms |
2404 KB |
Output is correct |
17 |
Correct |
0 ms |
2404 KB |
Output is correct |
18 |
Correct |
0 ms |
2404 KB |
Output is correct |
19 |
Correct |
0 ms |
2404 KB |
Output is correct |
20 |
Correct |
0 ms |
2404 KB |
Output is correct |
21 |
Correct |
0 ms |
2404 KB |
Output is correct |
22 |
Correct |
0 ms |
2544 KB |
Output is correct |
23 |
Correct |
23 ms |
5560 KB |
Output is correct |
24 |
Correct |
0 ms |
2544 KB |
Output is correct |
25 |
Correct |
0 ms |
2404 KB |
Output is correct |
26 |
Correct |
0 ms |
2404 KB |
Output is correct |
27 |
Correct |
0 ms |
2404 KB |
Output is correct |
28 |
Correct |
0 ms |
2404 KB |
Output is correct |
29 |
Correct |
9 ms |
5560 KB |
Output is correct |
30 |
Correct |
6 ms |
4024 KB |
Output is correct |