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>
//#include "functions.h"
#define FOR(x,y) for(int x = 0; x < y; x++)
#define ALLR(x) x.begin(),x.end()
#define con continue
#define ll long long
#define LINF LLONG_MAX
#define INF INT_MAX
#define pii pair<int,int>
#define vi vector <int>
#define pb push_back
#define F first
#define S second
#define len(x) x.length()
#define sz(x) x.size()
#define debug cout << "\nPass line " + to_string(__LINE__) + "\n"
using namespace std;
//#define debug cout << endl
int main() {
int n;
cin >> n;
vector <tuple<int,int,int> > ac;
FOR(j, n)
{
int q1,q2,q3;
cin >> q1 >> q2 >> q3;
ac.push_back(make_tuple(q3,q2,q1));
}
sort(ALLR(ac));
//reverse(ALLR(ac));
int m;
cin >> m;
vector <tuple<int,int,int> > order(m);
FOR(j, n)
{
int q1,q2,q3;
cin >> q1 >> q2 >> q3;
order.push_back(make_tuple(q3,q2,q1));
}
sort(ALLR(order));
reverse(ALLR(order));
int ans = 0;
FOR(j, m)
{
FOR(k, n)
{
if(get<1>(order[j]) <= get<1>(ac[j]) && get<0>(order[j]) - get<0>(ac[j]) >= 0)
{
ans += get<0>(order[j]) - get<0>(ac[j]);
ac.erase(ac.begin() + k);
break;
}
}
}
cout << ans;
}
# | 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... |