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;
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(15);
#pragma GCC optimize("Ofast")
typedef long long ll;
ll n,m,k,a,b,c,t;
struct algo
{
ll cost;
ll p;
ll g;
ll ip;
ll mp;
ll tr;
friend bool operator < (algo a, algo b)
{
if(a.cost!=b.cost)
return a.cost<b.cost;
return a.g<b.g;
}
};
int main()
{
cin>>n>>m>>k>>a>>b>>c>>t;
ll cad[m+1];
ll cont=0;
priority_queue<algo> q;
for(int i=0; i<m; i++)
cin>>cad[i];
cad[m]=cad[m-1]+1;
for(int i=0; i<m; i++)
{
ll temp=t-(cad[i]-1)*b;
q.push({1,cad[i],min(temp/a,cad[i+1]-cad[i]-1),cad[i],cad[i+1],temp});
}
while(k&&!q.empty())
{
k--;
algo temp=q.top();q.pop();
if(temp.tr<0) continue;
cont++;
cont+=max(temp.g,0LL);
ll asd=temp.tr-(temp.p+temp.g-temp.ip+1)*c;
//cout<<temp.cost<<" "<<temp.p<<" "<<temp.g<<" "<<temp.tr<<" "<<asd<<" "<<"\n";
q.push({0,temp.p+temp.g+1,min(asd/a,temp.mp-temp.p-temp.g-1-1),temp.ip,temp.mp,asd});
}
cout<<cont-1;
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... |