#include <iostream>
#include <fstream>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <iterator>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll INF=1e18+123;
const ld EPS=1e-9;
const int inf=1e9+123;
const int MOD=1e9+7;
const int N=1e5+123;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};
int s[N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,m,k;
cin>>n>>m>>k;
ll a,b,c,t;
cin>>a>>b>>c>>t;
for(int i=1;i<=m;i++){
cin>>s[i];
}
k-=m;
ll ans=0;
int lk=-1;
multiset<int>q;
for(int i=2;i<=m;i++){
ll d=(s[i-1]-1)*b;
if(d>t)break;
ans++;
int L=s[i-1];
while(L<s[i]-1){
int l=L+1,r=s[i];
while(l<r){
int mid=(l+r)/2;
if((mid-s[i-1]+0ll)*a+d<=t){
l=mid+1;
}
else r=mid;
}
r--;ans+=r-L;
if((r-s[i-1]+1)*c+d>t){
L=inf;
break;
}
int x=min((t-((r-s[i-1]+1)*c+d))/a+1,s[i]-r-1ll);
L=r;
if(sz(q)==k){
if(k && *q.begin()<x){
ans-=*q.begin();
q.erase(q.begin());
ans+=x;
L+=x;
q.insert(x);
}
else{
L=inf;
break;
}
}
else{
L+=x;
ans+=x;
q.insert(x);
}
}
}
ans+=((s[m]-1)*b<=t);
cout<<ans-1;
return 0;
}
Compilation message
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:59:9: warning: unused variable 'lk' [-Wunused-variable]
int lk=-1;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
456 KB |
Output is correct |
3 |
Correct |
3 ms |
456 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
2 ms |
560 KB |
Output is correct |
8 |
Correct |
3 ms |
560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
456 KB |
Output is correct |
3 |
Correct |
3 ms |
456 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
2 ms |
560 KB |
Output is correct |
8 |
Correct |
3 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
3 ms |
644 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
656 KB |
Output is correct |
15 |
Correct |
2 ms |
660 KB |
Output is correct |
16 |
Correct |
2 ms |
664 KB |
Output is correct |
17 |
Correct |
3 ms |
668 KB |
Output is correct |
18 |
Correct |
3 ms |
784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
456 KB |
Output is correct |
3 |
Correct |
3 ms |
456 KB |
Output is correct |
4 |
Correct |
2 ms |
456 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
2 ms |
560 KB |
Output is correct |
8 |
Correct |
3 ms |
560 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
3 ms |
644 KB |
Output is correct |
12 |
Correct |
2 ms |
648 KB |
Output is correct |
13 |
Correct |
2 ms |
652 KB |
Output is correct |
14 |
Correct |
2 ms |
656 KB |
Output is correct |
15 |
Correct |
2 ms |
660 KB |
Output is correct |
16 |
Correct |
2 ms |
664 KB |
Output is correct |
17 |
Correct |
3 ms |
668 KB |
Output is correct |
18 |
Correct |
3 ms |
784 KB |
Output is correct |
19 |
Correct |
3 ms |
784 KB |
Output is correct |
20 |
Correct |
2 ms |
784 KB |
Output is correct |
21 |
Correct |
3 ms |
784 KB |
Output is correct |
22 |
Correct |
3 ms |
784 KB |
Output is correct |
23 |
Correct |
2 ms |
784 KB |
Output is correct |
24 |
Correct |
3 ms |
784 KB |
Output is correct |
25 |
Correct |
3 ms |
784 KB |
Output is correct |
26 |
Correct |
4 ms |
784 KB |
Output is correct |
27 |
Correct |
3 ms |
784 KB |
Output is correct |
28 |
Correct |
3 ms |
784 KB |
Output is correct |
29 |
Correct |
3 ms |
784 KB |
Output is correct |
30 |
Correct |
3 ms |
784 KB |
Output is correct |