Submission #629921

#TimeUsernameProblemLanguageResultExecution timeMemory
629921NintsiChkhaidzeCloud Computing (CEOI18_clo)C++14
100 / 100
765 ms2036 KiB
#include <bits/stdc++.h> #include <iostream> #define ll long long #define s second #define pb push_back #define f first using namespace std; const int N = 100005; vector<pair<pair<int,int>,int> > vec; int tot; ll dpold[N],dpnew[N]; bool cmp(pair<pair<int,int>,int> a, pair<pair<int,int>,int> b){ if (a.f.s < b.f.s) return 0; if (a.f.s > b.f.s) return 1; return (a.f.f > b.f.f); } signed main() { int n; cin>>n; for (int i = 0; i < n; i++){ int c,f,v; cin>>c>>f>>v; tot += c; vec.pb({{c,f},-v}); } int m; cin>>m; for (int i = 0; i < m; i++){ int c,f,v; cin>>c>>f>>v; vec.pb({{-c,f},v}); } sort(vec.begin(),vec.end(),cmp); for (int i = 1;i <= tot; i++) dpold[i] = dpnew[i] = -1e18; for (int i = 0; i < vec.size(); i++){ int pr = vec[i].s,cr = vec[i].f.f; for (int j = 0; j <= tot; j++){ int nw = j + cr; if (nw < 0 || nw > tot || dpold[j] == -1e18) continue; dpnew[nw] = max(dpnew[nw], dpold[j] + pr); } for (int j = 0; j <= tot; j++) dpold[j] = dpnew[j]; } ll ans=0; for (int j = 0; j <= tot; j++) ans=max(ans,dpold[j]); cout<<ans; }

Compilation message (stderr)

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