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 <iostream>
#include <algorithm>
#include <set>
#define NMAX 500005
using namespace std;
int N, M, NRO;
int DIFF[NMAX];
long long ANS;
struct room
{
int cost, capacity;
} C[NMAX], A;
multiset <room> H;
multiset <room> :: iterator it;
bool operator < (const room &X, const room &Y)
{
if (X.capacity != Y.capacity)
return X.capacity < Y.capacity;
return X.cost < Y.cost;
}
struct offer
{
int price, dimension;
} O[NMAX];
bool cmpO(offer A, offer B)
{
return A.price>B.price;
}
int main()
{
cin >> N >> M >> NRO;
for (int i=1; i<=N; i++)
{
cin >> C[i].cost >> C[i].capacity;
H.insert(C[i]);
}
for (int i=1; i<=M; i++)
cin >> O[i].price >> O[i].dimension;
sort(O+1, O+M+1, cmpO);
for (int i=1; i<=M; i++)
{
A.cost=0;
A.capacity=O[i].dimension;
it=H.upper_bound(A);
if (it==H.end())
continue;
A=*it;
DIFF[i]=O[i].price-A.cost;
H.erase(it);
}
sort(DIFF+1, DIFF+M+1);
for (int i=M; i>M-NRO; i--)
if (DIFF[i]>0)
ANS+=DIFF[i];
cout << ANS;
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... |
# | 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... |