Submission #1059959

#TimeUsernameProblemLanguageResultExecution timeMemory
1059959kachim2Cloud Computing (CEOI18_clo)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<array<int, 3>> comp(n); for(int i = 0; i < n; i++){ cin >> comp[i][0] >> comp[i][1] >> comp[i][2]; } std::sort(comp.begin(), comp.end()); int m; cin >> m; vector<array<int, 3>> ord(m); for(int i = 0; i < m; i++){ cin >> ord[i][0] >> ord[i][1] >> ord[i][2]; } std::sort(ord.begin(), ord.end()); vector<pair<int, int>> a; vector<int> money; vector<bool> taken(n); int profit = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(comp[i][1] >= ord[j][1]){ a.push_back({i, ord[j][1]}); money.push_back(ord[j][2]); ord[j][1]=INT_MAX; taken[i]=1; } } } while(!a.empty()){ auto x = a.back(); a.pop_back(); taken[x.first] = 0; int mini = x.first; for(int i = 0; i < n; i++){ if(comp[i][1] >= x.second && comp[mini][2]>comp[i][2]){ mini = i; } } taken[mini] = 1; profit+=max(0, money.back()-comp[mini][2]); money.pop_back(); } cout << profit << '\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...