제출 #479862

#제출 시각아이디문제언어결과실행 시간메모리
479862TadiornCloud Computing (CEOI18_clo)C++14
72 / 100
1582 ms3400 KiB
#include <bits/stdc++.h> #define MAXN 2010 #define INF 100000000000000000LL using namespace std; struct data { int c; int f; int v; }; data a[2*MAXN]; bool cmp(data x, data y) { return x.f > y.f; } long long prevNiz[100*MAXN]; long long tr[100*MAXN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cerr.tie(0); int n; cin >> n; int i = 0; int C = 0; for(i = 0; i < n; i++) { cin >> a[i].c >> a[i].f >> a[i].v; C += a[i].c; a[i].v = -a[i].v; } int m; cin >> m; for(; i < n + m; i++) { cin >> a[i].c >> a[i].f >> a[i].v; C += a[i].c; a[i].c = -a[i].c; } for(int i = 0; i <= C; i++) { prevNiz[i] = -INF; } prevNiz[0] = 0; //cout << "CHECKPOINT 1" << endl; sort(a, a + m + n, cmp); for(int i = 0; i < n + m; i++) { //cout << "START" << endl; for(int j = 0; j <= C; j++) { //cout << "START 2" << endl; tr[j] = prevNiz[j]; if(j - a[i].c >= 0 && j - a[i].c <= C && prevNiz[j - a[i].c] + a[i].v > tr[j]) { tr[j] = prevNiz[j - a[i].c] + a[i].v; } //cout << "END 2" << endl; } //cout << "MID" << endl; for(int j = 0; j <= C; j++) { prevNiz[j] = tr[j]; } //cout << "END" << endl; } //cout << "CHECKPOINT 2" << endl; long long res = 0; for(int i = 0; i <= C; i++) { res = max(res, prevNiz[i]); } cout << res << endl; return 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...