#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>
using vvector = vector<vector<T>>;
int main() {
speed;
ll n,m,k;
cin>>n>>m>>k;
ll a,b,c;
cin>>a>>b>>c;
ll T;
cin>>T;
vector<ll> s(n+1);
for (int i=1;i<=m;i++) {
cin>>s[i];
s[i]--;
}
ll sp=k-m;
vvector<ll> rew(m+1,vector<ll>(sp+4));
for (int i=1;i<m;i++) {
ll now=(T+s[i]*(a-b))/a+1;
if (now<=s[i]) {
for (int k=0;k<=sp;k++) rew[i][k]=0;
continue;
}
for (int j=0;j<=sp;j++) {
if (now>=s[i+1]) {
for (int k=j;k<=sp;k++) rew[i][k]=s[i+1]-s[i];
break;
}
rew[i][j]=now-s[i];
// cout<<i<<" "<<j<<" "<<now<<" ij now\n";
now=(T+(a-c)*now+(c-b)*s[i])/a+1;
}
for (int j=sp;j>=1;j--) rew[i][j]-=rew[i][j-1];
// for (int j=0;j<=sp;j++) cout<<rew[i][j]<<" ";
// cout<<"\n";
}
priority_queue<pii> Q;
ll ans=0;
vector<int> pnt(m+1,1);
for (int i=1;i<m;i++) {
ans+=rew[i][0];
Q.push({rew[i][1],i});
}
for (int i=1;i<=sp;i++) {
auto [v,id]=Q.top();
Q.pop();
ans+=v;
Q.push({rew[id][++pnt[id]],id});
}
cout<<ans+(n*b-b<=T)-1<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |