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>
#define ll long long
using namespace std;
ll a,b,c,d,i,e,f,g,n,m,k,l,t,A[500005],l1,l2,ans,t1,t2;
multiset<ll> ms;
int main() {
cin>>n>>m>>k;
cin>>a>>b>>c;
cin>>t;
for(ll i=1;i<=m;i++) {
cin>>A[i];
}
for(ll i=1;i<m;i++) {
t1=t-b*(A[i]-1);
if(t1<0) break;
//cout<<i<<" "<<t-b*(A[i]-1)<<" ";
l=min(A[i]+(t1/a),A[i+1]-1);
ans+=(l-A[i]+1);
if(i==1) ans--;
//cout<<ans<<endl;
f=1; l1=A[i]; l++; t2=t1;
while(l<=A[i+1]-1 && f<=(k-m)) {
t2-=c*(l-l1);
if(t2<0) break;
//cout<<l<<" "<<l1<<endl;
l2=min(A[i+1]-1,l+(t2/a));
ms.insert(-(l2-l+1));
l1=l; l=l2+1;
f++;
}
}
if(A[m]*b<=t) ans++;
f=1;
while(ms.size() && f<=(k-m)) {
f++;
ans-=*ms.begin();
ms.erase(ms.find(*ms.begin()));
}
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... |