#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
int n, m, k, a, b, c, t;
cin >> n >> m >> k >> a >> c >> b >> t;
k -= m;
vector<int> v(m);
for (auto &i : v)
cin >> i, --i;
vector<vector<int>> add(m - 1, vector<int>(k + 1, 0));
for (int i = 0; i < m - 1; ++i)
{
int lft = t - c * v[i];
if (lft < 0)
continue;
add[i][0] = 1 + lft / a;
add[i][0] = min(add[i][0], v[i + 1] - v[i]);
lft -= b * add[i][0];
for (int j = 1; j <= k && lft >= 0; ++j)
{
add[i][j] = 1 + lft / a;
add[i][j] += add[i][j - 1];
add[i][j] = min(add[i][j], v[i + 1] - v[i]);
lft -= b * (add[i][j] - add[i][j - 1]);
}
}
// for (auto i : add)
// {
// for (auto j : i)
// cout << j << ' ';
// cout << '\n';
// }
vector<vector<int>> dp(m - 1, vector<int>(k + 1, 0));
dp[0] = add[0];
for (int i = 1; i < m - 1; ++i)
{
dp[i] = dp[i - 1];
for (int kk = 0; kk <= k; ++kk)
dp[i][kk] = max(dp[i][kk], dp[i - 1][kk] + add[i][0]);
for (int j = 1; j <= k; ++j)
for (int kk = j; kk <= k; ++kk)
dp[i][kk] = max(dp[i][kk], dp[i - 1][kk - j] + add[i][j]);
}
int ans = *max_element(dp[m - 2].begin(), dp[m - 2].end());
if (c * v.back() > t)
--ans;
cout << ans << '\n';
}
/*
10 3 5
10 3 5
30
1 6 10
10 3 5
10 3 5
25
1 6 10
90 10 12
100000 1000 10000
10000
1
10 20 30 40 50 60 70 80 90
*/
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
344 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 |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
600 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
114 ms |
10560 KB |
Output is correct |
20 |
Correct |
545 ms |
22864 KB |
Output is correct |
21 |
Correct |
1 ms |
600 KB |
Output is correct |
22 |
Correct |
9 ms |
3164 KB |
Output is correct |
23 |
Correct |
265 ms |
17192 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
1 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
71 ms |
5140 KB |
Output is correct |
30 |
Correct |
129 ms |
3164 KB |
Output is correct |