Submission #441679

#TimeUsernameProblemLanguageResultExecution timeMemory
441679linkretCloud Computing (CEOI18_clo)C++14
100 / 100
787 ms2048 KiB
#include <bits/stdc++.h> using namespace std; long long int dp [2][2010*50]; struct rac { int f, ku, v; }; vector < rac > k; int cmp (rac a, rac b){ if (a.f==b.f){ if (a.ku>b.ku) return 1; return 0; } if (a.f>b.f) return 1; return 0; } int main(){ int n,m; cin >> n; for (int i=0; i<n; i++) { int c,f,v; cin >> c >> f >> v; v=(-v); rac x; x.ku=c; x.f=f; x.v=v; k.push_back(x); } cin >> m; for (int i=0; i<m; i++) { int c,f,v; cin >> c >> f >> v; c=(-c); rac x; x.ku=c; x.f=f; x.v=v; k.push_back(x); } long long int sol=0; sort (k.begin(), k.end(), cmp); for (int j=1; j<2010*50; j++) dp[0][j]=-1e18; for (int i=0; i<k.size(); i++) { for (int j=0; j<2010*50; j++) { if (j<k[i].ku) dp[1][j]=dp[0][j]; else if (j-k[i].ku>=2010*50) dp[1][j]=dp[0][j]; else dp [1][j] = max (dp[0][j-k[i].ku]+k[i].v, dp[0][j]); } for (int j=0; j<2010*50; j++) dp[0][j]=dp[1][j]; } for (int j=0; j<2010*50; j++) sol=max (sol, dp[0][j]); cout << sol; return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<rac>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i=0; i<k.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...