Submission #672129

#TimeUsernameProblemLanguageResultExecution timeMemory
672129Quan2003Cloud Computing (CEOI18_clo)C++17
100 / 100
900 ms2132 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int sz=2e5+10; const int sz1 = 5e5 + 10; const int inf=1e6+1; int dp[sz]; long long ans[sz]; int n,q; vector<array<long long,3>>queries; struct comp{ long long c,r,p; bool operator<(comp B){ if(r == B.r) return p < B.p; else return r > B.r; } }; int main(){ scanf("%d",&n); vector<comp>pay; long long cbound = 0; for(int i = 1; i <= n; i++){ comp go; scanf("%lld%lld%lld",&go.c,&go.r,&go.p); go.p = - go.p; pay.push_back(go); cbound += go.c; } scanf("%d",&q); for(int i = 1; i <= q; i++){ comp go; scanf("%lld%lld%lld",&go.c,&go.r,&go.p); go.c = - go.c; pay.push_back(go); } sort(pay.begin(),pay.end()); vector<long long>opt(cbound + 1, -LLONG_MAX); opt[0] = 0; for(int i = 0; i < pay.size();i++){ vector<long long>dp = opt; for(int j = 0; j <= cbound; j++){ int cur = j - pay[i].c; if(cur < 0 or cur > cbound or opt[cur] == -LLONG_MAX) continue; dp[j] = max(dp[j], opt[cur] + pay[i].p); } opt = dp; } cout<<(*max_element(opt.begin(),opt.end())); }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:39:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<comp>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |        for(int i = 0; i < pay.size();i++){
      |                       ~~^~~~~~~~~~~~
clo.cpp:19:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |        scanf("%d",&n);
      |        ~~~~~^~~~~~~~~
clo.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |             scanf("%lld%lld%lld",&go.c,&go.r,&go.p);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:29:13: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |        scanf("%d",&q);
      |        ~~~~~^~~~~~~~~
clo.cpp:32:17: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |            scanf("%lld%lld%lld",&go.c,&go.r,&go.p);
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...