# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
322622 | daniel920712 | Semiexpress (JOI17_semiexpress) | C++14 | 3 ms | 748 KiB |
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 <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
using namespace std;
long long all[3005];
map < long long , long long > Con;
set < long long > have,have2;
vector < long long > how;
priority_queue < pair < long long , pair < long long , long long > > , vector < pair < long long , pair < long long , long long > > > , less < pair < long long , pair < long long , long long > > > > ttt;
bool F(long long a,long long b)
{
return a>b;
}
int main()
{
//freopen("01-01.txt","rt",stdin);
long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
scanf("%lld %lld %lld",&N,&M,&K);
scanf("%lld %lld %lld",&a,&b,&c);
scanf("%lld",&t);
for(i=0;i<M;i++)
{
scanf("%lld",&all[i]);
have.insert(all[i]);
have2.insert(all[i]);
}
con=M;
ans+=min(t/a,N-1);
xx=t/a+1;
//printf("%lld\n",ans);
for(i=0;i<M-1;i++)
{
if((all[i]-1)*b<=t)
{
l=all[i];
r=(t-(all[i]-1)*b)/a+all[i];
r=min(r,all[i+1]-1);
if(r>xx)
{
if(l<=xx) ans+=max((long long) 0,(r-xx));
else ans+=r-l+1;
}
l=max(r+1,xx+1);
Con[l]=(*prev(have.lower_bound(l))-1)*b+c*(l-*prev(have.lower_bound(l)));
if(Con[l]<=t&&l>=all[i]&&l<all[i+1])
{
r=min(*have.lower_bound(l)-1,l+(t-Con[l])/a);
ttt.push(make_pair(r-l+1,make_pair(i,r)));
}
}
}
if((all[M-1]-1)*b<=t&&(all[M-1]-1)*a>t) ans++;
while(!ttt.empty()&&con<K)
{
con++;
ans+=max((long long) 0,ttt.top().first);
x=ttt.top().second.first;
r=ttt.top().second.second;
ttt.pop();
l=max(r+1,xx+1);
Con[l]=(all[x]-1)*b+c*(l-all[x]);
if(Con[l]<=t&&l>=all[x]&&l<all[x+1])
{
r=min(all[x+1]-1,l+(t-Con[l])/a);
ttt.push(make_pair(r-l+1,make_pair(x,r)));
}
}
printf("%lld\n",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |