#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){
ll ak=lim/a+1;
// cout<<lim<<" ";
if(lim<0 && bl){
k--;
}
if(lim<0 || (!bl && zna.size()>=K))return;
if(ak>=ile){
//cout<<"xd";
if(bl){
k--;
ans+=ile;
}
else
dod.pb(ile);
//cout<<ile<<"d ";
}
else{
if(bl){
k--;
ans+=ak;
}
else
zna.pb(ak);
//cout<<ak<<"z ";
calculate(ile-ak,lim-(ak)*c,0);
}
}
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);
// if(zna.size()>=K)break;
}
for(ll i : dod)zna.pb(i);
sort(zna.begin(),zna.end());
k--;
while(zna.size() && k){
k--;
ans+=zna.back();
zna.pop_back();
}
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... |