This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const long long maxn=3000+10;
long long n,m,k,a,b,c,t,inf=1e9+5;
long long all[maxn];
pair<long long,long long> cal(long long now,long long val,long long maxa){
pair<long long,long long>ret;
if(val>t){
return make_pair(-1,-1);
}
long long av=now+(t-val)/a+1;
ret.first=av;
if(av>maxa){
return make_pair(-1,-1);
}
long long dov=av+(t-val-(av-now)*c)/a+1;
if(t-val-(av-now)*c<0){
return make_pair(-1,-1);
}
ret.second=min(dov,maxa)-av;
return ret;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>k>>a>>b>>c;
cin>>t;
n--;
inf=n;
for(long long i=0;i<m;i++){
cin>>all[i];
all[i]--;
}
vector<long long>alle;
long long res=0;
for(long long i=0;i<m;i++){
long long z=min(a,min(b,c))*all[i];
pair<long long,long long>next=cal(all[i],z,i<m-1?all[i+1]:inf);
if(z<=t){
res+=min((t-z)/a+1,(i<m-1?all[i+1]:inf+1)-all[i]);
}
//cout<<next.first<<" "<<next.second<<" "<<all[i]<<endl;
long long te=0;
while(next.second>0&&te<=k-m){
te++;
alle.push_back(next.second);
next=cal(next.first,z+(next.first-all[i])*c,i<m-1?all[i+1]:inf);
// cout<<next.first<<" "<<next.second<<" "<<all[i]<<endl;
}
}
sort(alle.rbegin(),alle.rend());
for(long long i=0;i<min(k-m,(long long)alle.size());i++){
res+=alle[i];
}
res--;
cout<<res<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |