Submission #240405

#TimeUsernameProblemLanguageResultExecution timeMemory
240405m3r8Cloud Computing (CEOI18_clo)C++14
100 / 100
700 ms1536 KiB
#include <stdio.h> #include <vector> #include <algorithm> #include <utility> #include <functional> #define ll long long #define INF 10e12 #define MINF -INF #define N (2010 * 55) struct lli{ int cores; ll freq; ll price; }; int comp(lli a, lli b){ return a.freq > b.freq; }; ll dp[N]; std::vector<lli> ord; std::vector<lli> com; int main(void){ int n,m; scanf("%d",&n); int c,f,v; for(int i = 0;i<n;i++){ scanf("%d %d %d",&c,&f,&v); com.push_back({c,f,v}); }; scanf("%d",&m); for(int i = 0;i<m;i++){ scanf("%d %d %d",&c,&f,&v); ord.push_back({c,f,v}); }; std::sort(com.begin(),com.end(),comp); std::sort(ord.begin(),ord.end(),comp); for(int i = 1;i<N;i++){ dp[i] = MINF; }; ll mx = 0; int il = 0; int ir = 0; while(ir < ord.size()){ if(il < com.size() && com[il].freq >= ord[ir].freq){ c = com[il].cores; for(int i = N-1;i>=0;i--){ if(dp[i] != MINF){ dp[i+c] = std::max(dp[i+c],dp[i] - com[il].price); mx = std::max(mx,dp[i+c]); }; }; il++; }else{ c = ord[ir].cores; for(int i = c;i<N;i++){ if(dp[i] != MINF){ dp[i-c] = std::max(dp[i-c],dp[i] + ord[ir].price); mx = std::max(mx,dp[i-c]); }; }; ir++; }; }; printf("%lld\n",mx); return 0; };

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:49:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(ir < ord.size()){
         ~~~^~~~~~~~~~~~
clo.cpp:50:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(il < com.size() && com[il].freq >= ord[ir].freq){
        ~~~^~~~~~~~~~~~
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:32: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);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
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:37: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...