#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000009
#define INF 1000000019
#define INFL 1000000000000000099LL
ll n,q,s,t,a,b,c,d,ans,k,m,K;
vector<ll>szy,zna,dod;
void calculate(ll ile,ll lim,bool bl){
if(lim>=0)
{
ll ak=lim/a;
ak++;
if(ak>=ile)
ans+=ile;
else{
ans+=ak;
}
ile-=ak;
lim-=ak*c;
// cout<<ak<<" ";
}
k--;
while(lim>=0 && ile>0){
ll ak=lim/a;
ak++;
//cout<<ak<<" ";
if(ak>=ile)
dod.pb(ile);
else{
zna.pb(ak);
}
ile-=ak;
lim-=ak*c;
if(zna.size()>=K+7)return;
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m>>k>>a>>b>>c>>t;
K=k;
for(ll i=0;i<m;i++){
cin>>d;
d--;
szy.pb(d);
if(i)calculate(szy[i]-szy[i-1],t-b*szy[i-1],1);
}
for(ll i : dod)zna.pb(i);
sort(zna.begin(),zna.end());
k--;
while(zna.size() && k){
k--;
ans+=zna.back();
zna.pop_back();
}
while(k && ans<n-1)K++;
if((n-1)*b>t)ans--;
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |