Submission #1006849

#TimeUsernameProblemLanguageResultExecution timeMemory
1006849andecaandeciCloud Computing (CEOI18_clo)C++17
54 / 100
262 ms1392 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, m, inf = 1e15; priority_queue<pair<pair<int, int>, pair<int, int>>> pq; int dp[200005]; int c, f, v, a, ran = 0; signed main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); for(int i = 1; i <= 100000; i++) { dp[i] = inf; } cin >> n; for(int i = 0; i < n; i++) { cin >> c >> f >> v; pq.push({{f, c}, {v, 1}}); } cin >> m; for(int i = 0; i < m; i++) { cin >> c >> f >> v; pq.push({{f, c}, {v, 2}}); } while(!pq.empty()) { c = pq.top().first.second; v = pq.top().second.first; a = pq.top().second.second; pq.pop(); if(a == 1) { for(int i = 100000; i >= 0; i--) { dp[i + c] = min(dp[i + c], dp[i] + v); } ran += c; } else { for(int i = c; i <= 100000; i++) { dp[i - c] = min(dp[i - c], dp[i] - v); } } } int mini = 0; for(int i = 0; i <= 100000; i++) { mini = min(dp[i], mini); } mini *= -1; cout << mini << "\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...