Submission #725123

#TimeUsernameProblemLanguageResultExecution timeMemory
725123TAhmed33Cloud Computing (CEOI18_clo)C++98
100 / 100
1818 ms4528 KiB
#include <bits/stdc++.h> using namespace std; #define int long long vector <vector <int>> arr; int n; signed main () { cin >> n; for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; arr.push_back({a, b, -c}); } cin >> n; for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; arr.push_back({-a, b, c}); } sort(arr.begin(), arr.end(), [] (vector <int> &a, vector <int> &b) { if (a[1] == b[1]) return a[2] > b[2]; return a[1] < b[1]; }); n = arr.size(); int dp[50 * 5000 + 1]; for (int i = 0; i < 50 * 5000 + 1; i++) dp[i] = 0; for (int i = 0; i < n; i++) { vector <int> nn(50 * 5000 + 1); for (int j = 0; j < 50 * 5000 + 1; j++) { int sum = dp[j]; if (j + arr[i][0] >= 0) sum = max(sum, arr[i][2] + dp[j + arr[i][0]]); nn[j] = sum; } for (int j = 0; j < 50 * 5000 + 1; j++) dp[j] = nn[j]; } cout << dp[0] << '\n'; }
#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...