제출 #926755

#제출 시각아이디문제언어결과실행 시간메모리
926755doducanhCloud Computing (CEOI18_clo)C++14
72 / 100
464 ms2016 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxx=-1e18-7; struct compu { int c,f,w; }; bool cmp(compu a, compu b) { return a.f>b.f||(a.f==b.f&&a.w<a.w); } vector<compu>v; int dp[100005]; int dq[100005]; int n,q; main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n; int c,f,w; int s=0; for(int i=1;i<=n;i++){ cin>>c>>f>>w; s+=c; v.push_back({c,f,-w}); } cin>>q; for(int i=1;i<=q;i++){ cin>>c>>f>>w; v.push_back({-c,f,w}); } sort(v.begin(),v.end(),cmp); for(int i=0;i<=s;i++)dp[i]=maxx; for(int i=0;i<=s;i++)dq[i]=maxx; dp[0]=0; dq[0]=0; for(int i=0;i<v.size();i++){ for(int j=0; j<=s;j++) { int pre=j-v[i].c; if(pre>=0&&pre<=s&&dp[pre]!=maxx) dq[j]=max(dq[j],dp[pre]+v[i].w); } for(int i=0;i<=s;i++)dp[i]=dq[i]; } int res=0; for(int i=0;i<=s;i++)res=max(res,dp[i]); cout<<res; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'bool cmp(compu, compu)':
clo.cpp:12:35: warning: self-comparison always evaluates to false [-Wtautological-compare]
   12 |     return a.f>b.f||(a.f==b.f&&a.w<a.w);
      |                                ~~~^~~~
clo.cpp: At global scope:
clo.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main()
      | ^~~~
clo.cpp: In function 'int main()':
clo.cpp:39:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<compu>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
#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...