Submission #580321

#TimeUsernameProblemLanguageResultExecution timeMemory
580321juggernautCloud Computing (CEOI18_clo)C++14
54 / 100
52 ms404 KiB
#include<bits/stdc++.h> #define fr first #define sc second using namespace std; typedef long long ll; typedef long double ld; #define USING_ORDERED_SET 0 #if USING_ORDERED_SET #include<bits/extc++.h> using namespace __gnu_pbds; template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; #endif template<class T>void umax(T &a,T b){if(a<b)a=b;} template<class T>void umin(T &a,T b){if(b<a)a=b;} #ifdef juggernaut #define printl(args...) printf(args) #else #define printl(args...) 0 #endif struct dat{ int core; int freq; int cost; }a[4005]; int n,m; bool cmp(dat l,dat r){ if(l.freq==r.freq)return l.cost<r.cost; return l.freq>r.freq; } const int MX=10000; ll dp[MX+5]; int main(){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost); a[i].cost*=-1; } fill(dp,dp+MX+5,-1e15); dp[0]=0; scanf("%d",&m); for(int i=n;i<n+m;i++)scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost); sort(a,a+n+m,cmp); for(int i=0;i<n+m;i++){ if(a[i].cost<0){ for(int j=MX;j>=a[i].core;j--) umax(dp[j],dp[j-a[i].core]+a[i].cost); }else{ for(int j=0;j<=MX-a[i].core;j++) umax(dp[j],dp[j+a[i].core]+a[i].cost); } } for(int i=1;i<=MX;i++)umax(dp[i],dp[i-1]); cout<<dp[MX]; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
clo.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |  scanf("%d",&m);
      |  ~~~~~^~~~~~~~~
clo.cpp:41:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  for(int i=n;i<n+m;i++)scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
      |                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...