This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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][1] >> comp[i][2] >> comp[i][0];
}
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][1] >> ord[i][2] >> ord[i][0];
}
std::sort(ord.rbegin(), ord.rend());
int profit = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(comp[i][2] >= ord[j][2]){
profit+=max(0, ord[j][0]-comp[i][0]);
ord[j][2]=INT_MAX;
}
}
}
cout << profit << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |