Submission #134141

#TimeUsernameProblemLanguageResultExecution timeMemory
134141dragonslayeritCloud Computing (CEOI18_clo)C++14
100 / 100
393 ms1280 KiB
#include <cstdio> #include <algorithm> const long long INF=1e15+7; struct Event{ enum{ TYPE_COMPUTER=1, TYPE_CUSTOMER=2, }type; int C,F,V; void read(){ scanf("%d %d %d",&C,&F,&V); } bool operator<(Event e)const{ if(F!=e.F) return F>e.F; return type<e.type; } }events[4000]; long long profit[100001]; void setmax(long long& x,long long y){ x=std::max(x,y); } int main(){ int N; scanf("%d",&N); for(int i=0;i<N;i++){ events[i].read(); events[i].type=Event::TYPE_COMPUTER; } int M; scanf("%d",&M); for(int i=0;i<M;i++){ events[N+i].read(); events[N+i].type=Event::TYPE_CUSTOMER; } std::sort(events,events+N+M); std::fill(profit+1,profit+100001,-INF); for(int i=0;i<N+M;i++){ switch(events[i].type){ case Event::TYPE_CUSTOMER: for(int x=events[i].C;x<=100000;x++){ setmax(profit[x-events[i].C],profit[x]+events[i].V); } break; case Event::TYPE_COMPUTER: for(int x=100000;x>=events[i].C;x--){ setmax(profit[x],profit[x-events[i].C]-events[i].V); } break; } /* for(int x=0;x<=100000;x++){ if(profit[x]>-INF/2){ printf("%d: %lld\n",x,profit[x]); } } */ } printf("%lld\n",*std::max_element(profit,profit+100001)); }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&N);
   ~~~~~^~~~~~~~~
clo.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&M);
   ~~~~~^~~~~~~~~
clo.cpp: In member function 'void Event::read()':
clo.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&C,&F,&V);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...