Submission #151418

#TimeUsernameProblemLanguageResultExecution timeMemory
151418TadijaSebez만두 (JOI14_ho_t2)C++11
100 / 100
14 ms540 KiB
#include <bits/stdc++.h> using namespace std; const int M=20050; const int inf=1e9+7; int p[M],dp[M]; int main() { int n,m,c,e; scanf("%i %i",&m,&n); for(int i=1;i<=m;i++) scanf("%i",&p[i]); sort(p+1,p+1+m);reverse(p+1,p+1+m); for(int i=1;i<M;i++) dp[i]=inf; while(n--) { scanf("%i %i",&c,&e); for(int i=M-1;i>=c;i--) dp[i]=min(dp[i],dp[i-c]+e); } for(int i=m+1;i<M;i++) dp[m]=min(dp[m],dp[i]); int ans=0; for(int i=1;i<=m;i++) p[i]+=p[i-1],ans=max(ans,p[i]-dp[i]); printf("%i\n",ans); return 0; }

Compilation message (stderr)

2014_ho_t2.cpp: In function 'int main()':
2014_ho_t2.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&m,&n);
  ~~~~~^~~~~~~~~~~~~~~
2014_ho_t2.cpp:10:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=m;i++) scanf("%i",&p[i]);
                        ~~~~~^~~~~~~~~~~~
2014_ho_t2.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i %i",&c,&e);
   ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...