Submission #888316

#TimeUsernameProblemLanguageResultExecution timeMemory
888316amirhoseinfar1385Semiexpress (JOI17_semiexpress)C++17
100 / 100
13 ms6356 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...