제출 #1319073

#제출 시각아이디문제언어결과실행 시간메모리
1319073aaaaaaaaCloud Computing (CEOI18_clo)C++20
0 / 100
2 ms336 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define int long long vector<vector<int>> v; signed main(){ ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); int n, m, cores = 0; cin >> n; for(int i = 0, a, b, c; i < n; ++i){ cin >> a >> b >> c; v.push_back({b, 1, a, c}); cores += a; } cin >> m; for(int i = 0, a, b, c; i < m; ++i){ cin >> a >> b >> c; v.push_back({b, 0, a, c}); cores += a; } sort(all(v)); vector<int> dp(cores + 5, 0); for(int i = 0; i < v.size(); ++i){ vector<int> ndp(cores + 5, 0); for(int j = 0; j <= cores; ++j){ ndp[j] = dp[j]; if(v[i][1] == 0){ if(j + v[i][2] <= cores) ndp[j] = max(ndp[j], (int) dp[j + v[i][2]] - v[i][3]); }else{ if(v[i][2] <= j){ ndp[j] = max(ndp[j], (int) dp[j - v[i][2]] + v[i][3]); } } } swap(dp, ndp); } cout << dp[0] << "\n"; 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...