제출 #291946

#제출 시각아이디문제언어결과실행 시간메모리
291946ngotienhungCloud Computing (CEOI18_clo)C++14
72 / 100
477 ms1272 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second using namespace std; //20 1 -9999 //4 1 -700 //4 1 -750 //2 1 -10 //-1 1 300 //-3 1 4550 //-6 1 1500 //4890 const int maxN = 1e5 + 10; 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; } int32_t main() { ios_base::sync_with_stdio(); cin.tie(); cout.tie(); //freopen("CC.inp", "r", stdin); 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); 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...