Submission #322622

#TimeUsernameProblemLanguageResultExecution timeMemory
322622daniel920712Semiexpress (JOI17_semiexpress)C++14
100 / 100
3 ms748 KiB
#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)

semiexpress.cpp: In function 'int main()':
semiexpress.cpp:24:29: warning: unused variable 'y' [-Wunused-variable]
   24 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
      |                             ^
semiexpress.cpp:24:31: warning: unused variable 'z' [-Wunused-variable]
   24 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
      |                               ^
semiexpress.cpp:24:47: warning: unused variable 'now' [-Wunused-variable]
   24 |     long long N,M,K,a,b,c,x,y,z,t,ans=0,con=0,now=0,i,l,r,xx;
      |                                               ^~~
semiexpress.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |     scanf("%lld %lld %lld",&N,&M,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%lld %lld %lld",&a,&b,&c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |     scanf("%lld",&t);
      |     ~~~~~^~~~~~~~~~~
semiexpress.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |         scanf("%lld",&all[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...