#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;int M;int K;
int B;int C;int A;
int T;
int ar[200005];
signed main(){
cin>>n>>M>>K;
cin>>A>>C>>B;
cin>>T;
for(int i=1;i<=M;i++){
cin>>ar[i];
}
ar[M+1]=n+1;
int ans=0;
K-=M;
priority_queue<pair<int,pair<int,int>>>pq;
for(int i=1;i<=M;i++){
if((ar[i]-1)*C>T){continue;}
int t=T-(ar[i]-1)*C;
t/=A;
int pl=ar[i]+t;
pl=min(pl,ar[i+1]-1);
ans+=pl-ar[i]+1;
int opl=pl;
if(pl!=ar[i+1]-1){
t=T-(ar[i]-1)*C;
t-=(pl+1-ar[i])*B;
if(t<0){continue;}
int lpl=pl+1;
t/=A;
int rpl=min(lpl+t,ar[i+1]-1);
pq.push({rpl-lpl+1,{i,rpl}});
}
}
while(pq.size()&&K--){
int i=pq.top().second.first;
int pl=pq.top().second.second;
ans+=pq.top().first;
pq.pop();
int t;
if(pl!=ar[i+1]-1){
t=T-(ar[i]-1)*C;
t-=(pl+1-ar[i])*B;
if(t<0){continue;}
int lpl=pl+1;
t/=A;
int rpl=min(lpl+t,ar[i+1]-1);
pq.push({rpl-lpl+1,{i,rpl}});
}
}
cout<<ans-1<<endl;
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:30:9: warning: unused variable 'opl' [-Wunused-variable]
30 | int opl=pl;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
404 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
320 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
320 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
312 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |