이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int)a.size()
const int mxN = (int)5e5+10;
using ar = array<int,2>;
ar a[mxN];
int n, m, k, x, y;
int32_t main(){
cin >> n >> m >> k; multiset<pair<int,int>> Ms;
for(int i = 0; i < n; i++) cin >> x >> y, Ms.insert({y,x});
for(int i = 0; i < m; i++) cin >> a[i][0] >> a[i][1];
multiset<int,greater<>> S; int ans = 0; sort(a,a+m);
for(int i = m-1; i >= 0; i--){
auto itr=Ms.lower_bound({a[i][1],0});
if(itr!=end(Ms) and itr->second < a[i][0])
S.insert(a[i][0]-itr->second), Ms.erase(itr);
}
while(k-- and sz(S)) ans+=max(0ll,*begin(S)), S.erase(begin(S));
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... |
# | 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... |