제출 #291941

#제출 시각아이디문제언어결과실행 시간메모리
291941ngotienhungCloud Computing (CEOI18_clo)C++14
18 / 100
470 ms892 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second using namespace std; const int maxN = 2005; const int maxC = 2000 * 50 + 69; const int inf = 1e9 + 10; struct TCom{int c,f,v;}; int n,m; int mark[maxN]; int f[maxC]; TCom a[maxN * 2]; bool cmp(TCom a, TCom b){ return a.f > b.f; } int main() { ios_base::sync_with_stdio(); cin.tie(); cout.tie(); cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i].c >> a[i].f >> a[i].v; cin >> m; for(int i = 1; i <= m; ++i) cin >> a[i + n].c >> a[i + n].f >> a[i + n].v; for(int i = 1; i <= n; ++i) a[i].v = -a[i].v; for(int i = n + 1; i <= n + m; ++i) a[i].c = -a[i].c; sort(a + 1, a + n + m + 1, cmp); //for(int i = 1; i <= n + m + 1; ++i) // cout << a[i].c << " " << a[i].f << " " << a[i].v << endl; memset(f, 0, sizeof(f)); for(int i = n + m; i >= 1; --i){ if(a[i].v < 0){ for(int j = 0; j <= maxC; ++j) if(j + a[i].c >= 0 && j + a[i].c <= maxC) f[j] = max(f[j], f[j + a[i].c] + a[i].v); } else{ for(int j = maxC; j >= 0; --j) if(j + a[i].c >= 0 && j + a[i].c <= maxC) f[j] = max(f[j], f[j + a[i].c] + a[i].v); } } cout << f[0]; }
#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...