#include <bits/stdc++.h>
#define M 3005
#define f first
#define s second
using namespace std;
typedef long long ll;
ll A, B, C, W, n, m, k, S[M], dp[M], ans = -1;
vector<ll> val;
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n>>m>>k>>A>>B>>C>>W;
for(int i = 1; i <= m; i++) cin>>S[i];
for(int i = 1; i < m; i++)
{
ll st = (S[i] - 1)*B, pos = min(S[i + 1] - 1, S[i] + (W - st)/A);
if(st > W) continue;
ans += (pos - S[i] + 1);
for(int cnt = 1; cnt <= k && pos <= S[i + 1] - 2; cnt ++)
{
ll st_2 = st + (pos + 1 - S[i])*C;
if(st_2 > W) continue;
ll nxt = min(S[i + 1] - 1, 1 + pos + (W - st_2)/A);
val.push_back(nxt - pos);
pos = nxt;
}
}
sort(val.rbegin(), val.rend());
for(int i = 0; i < min(k - m, (ll)val.size()); i++) ans += val[i];
if((n - 1)*B <= W) ans ++;
cout<<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
352 KB |
Output is correct |
3 |
Correct |
1 ms |
424 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
440 KB |
Output is correct |
6 |
Correct |
2 ms |
440 KB |
Output is correct |
7 |
Correct |
1 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
352 KB |
Output is correct |
3 |
Correct |
1 ms |
424 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
440 KB |
Output is correct |
6 |
Correct |
2 ms |
440 KB |
Output is correct |
7 |
Correct |
1 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
11 |
Correct |
1 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
1 ms |
640 KB |
Output is correct |
14 |
Correct |
1 ms |
640 KB |
Output is correct |
15 |
Correct |
1 ms |
640 KB |
Output is correct |
16 |
Correct |
2 ms |
640 KB |
Output is correct |
17 |
Correct |
1 ms |
656 KB |
Output is correct |
18 |
Correct |
1 ms |
692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
248 KB |
Output is correct |
2 |
Correct |
1 ms |
352 KB |
Output is correct |
3 |
Correct |
1 ms |
424 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
440 KB |
Output is correct |
6 |
Correct |
2 ms |
440 KB |
Output is correct |
7 |
Correct |
1 ms |
496 KB |
Output is correct |
8 |
Correct |
1 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
640 KB |
Output is correct |
10 |
Correct |
1 ms |
640 KB |
Output is correct |
11 |
Correct |
1 ms |
640 KB |
Output is correct |
12 |
Correct |
2 ms |
640 KB |
Output is correct |
13 |
Correct |
1 ms |
640 KB |
Output is correct |
14 |
Correct |
1 ms |
640 KB |
Output is correct |
15 |
Correct |
1 ms |
640 KB |
Output is correct |
16 |
Correct |
2 ms |
640 KB |
Output is correct |
17 |
Correct |
1 ms |
656 KB |
Output is correct |
18 |
Correct |
1 ms |
692 KB |
Output is correct |
19 |
Correct |
2 ms |
696 KB |
Output is correct |
20 |
Correct |
2 ms |
712 KB |
Output is correct |
21 |
Correct |
11 ms |
2908 KB |
Output is correct |
22 |
Correct |
7 ms |
2908 KB |
Output is correct |
23 |
Correct |
35 ms |
9164 KB |
Output is correct |
24 |
Correct |
35 ms |
9164 KB |
Output is correct |
25 |
Correct |
1 ms |
9164 KB |
Output is correct |
26 |
Correct |
2 ms |
9164 KB |
Output is correct |
27 |
Correct |
115 ms |
17480 KB |
Output is correct |
28 |
Correct |
139 ms |
33876 KB |
Output is correct |
29 |
Correct |
27 ms |
33876 KB |
Output is correct |
30 |
Correct |
11 ms |
33876 KB |
Output is correct |