#include <bits/stdc++.h>
#pragma GCC optimize("trapv")
#define IO_OP ios::sync_with_stdio(0), cin.tie(0)
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emaplce_back
#define MP make_pair
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
const int INF = 1e9 + 7, N = 3005;
int s[N];
signed main()
{
IO_OP;
int n, m, k, a, b, c;
ll t;
cin >> n >> m >> k >> a >> b >> c >> t;
assert(k >= m);
k -= m;
int ans = 0;
for(int i = 0; i < m; i++) {
cin >> s[i];
}
vi tt;
for(int i = 0; i < m - 1; i++) {
ll now = 1LL * (s[i] - 1) * b;
int pos = s[i];
vi aux;
while(now <= t && pos < s[i + 1] && int(aux.size()) < k + 1) {
// now + a * x <= t
// pos + x < s[i + 1]
ll x = min<ll>((t - now) / a, s[i + 1] - pos - 1);
assert(x >= 0);
aux.PB(x + 1);
pos = pos + x + 1;
now += 1LL * (x + 1) * c;
}
if(aux.size()) {
ans += aux[0];
for(int i = 1; i < int(aux.size()); i++) {
assert(aux[i] <= aux[i - 1]);
tt.PB(aux[i]);
}
}
}
if(1LL * (s[m - 1] - 1) * b <= t)
ans++;
sort(ALL(tt), greater<int>());
for(int i = 0; i < min(int(tt.size()), k); i++)
ans += tt[i];
ans--;
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
0 ms |
208 KB |
Output is correct |
13 |
Correct |
0 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
0 ms |
208 KB |
Output is correct |
16 |
Correct |
1 ms |
208 KB |
Output is correct |
17 |
Correct |
1 ms |
208 KB |
Output is correct |
18 |
Correct |
0 ms |
208 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
2 ms |
464 KB |
Output is correct |
23 |
Correct |
17 ms |
2504 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
2 ms |
336 KB |
Output is correct |
29 |
Correct |
19 ms |
2504 KB |
Output is correct |
30 |
Correct |
8 ms |
1480 KB |
Output is correct |