#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,m,o;
ll out;
int main()
{
cin>>n>>m>>o;
set<vl>s;
for (int i = 0;i<n;i++){ll x,y;cin>>x>>y;s.insert({y,x,i + 1});}
vl profits;
vvl offers(m,vl(2));
for (int i = 0;i<m;i++)cin>>offers[i][0]>>offers[i][1];
sort(offers.begin(),offers.end(),greater<vl>());
for (int i = 0;i<o;i++){
auto it = s.lower_bound({offers[i][1],0,0});
if (it == s.end())continue;
profits.pb(offers[i][0] - (*it)[1]);
s.erase(it);
}
sort(profits.begin(),profits.end(),greater<ll>());
for (int i = 0;i<min(o,(int)profits.size());i++)if (profits[i] > 0)out += profits[i];
cout<<out;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
1488 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
102 ms |
6404 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
212 ms |
11956 KB |
Output is correct |
2 |
Incorrect |
126 ms |
9180 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
724 ms |
32280 KB |
Output is correct |
2 |
Incorrect |
292 ms |
20824 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1292 ms |
60408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1570 ms |
74708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |