#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
int s[200100];
signed main(){
int n, m, k;
cin>>n>>m>>k;
int a, b, c;
cin>>a>>b>>c;
ll t;
cin>>t;
for(int i=1; i<=m; i++){
cin>>s[i];
}
multiset<int> q;
int ans = -1;
for(int i=1; i<m; i++){
//cout<<"#####################\n";
//cout<<s[i]<<'\n';
if((s[i] - 1) * b > t) continue;
if((t - (s[i] - 1) * b) / a + 1 > s[i + 1] - s[i]){
ans += s[i + 1] - s[i];
continue;
}
ans += (t - (s[i] - 1) * b) / a + 1;
int ls = s[i] + (t - (s[i] - 1) * b) / a;
//cout<<ls<<'\n';
for(int j=1; j<=k-m; j++){
if((s[i] - 1) * b + (ls + 1 - s[i]) * c > t) break;
int x = (t - ((s[i] - 1) * b + (ls + 1 - s[i]) * c))/a + 1;
if(x > s[i + 1] - (ls + 1)){
q.insert(s[i + 1] - (ls + 1));
break;
}
//cout<<ls<<' '<<x<<'\n';
q.insert(x);
ls = ls + 1 + x - 1;
}
}
if((n-1) * b <= t) ans ++;
for(int i=0; i<k-m and q.size(); i++){
auto it = q.end();
it--;
//cout<<*it<<'\n';
ans += *it;
q.erase(it);
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
440 KB |
Output is correct |
3 |
Correct |
0 ms |
440 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
440 KB |
Output is correct |
3 |
Correct |
0 ms |
440 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 |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
444 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
444 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 |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
440 KB |
Output is correct |
3 |
Correct |
0 ms |
440 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 |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
444 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
444 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 |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
964 KB |
Output is correct |
23 |
Correct |
50 ms |
19892 KB |
Output is correct |
24 |
Correct |
2 ms |
600 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
604 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
35 ms |
14160 KB |
Output is correct |
30 |
Correct |
21 ms |
8792 KB |
Output is correct |