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;
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
pii tab[500009];
bool vis[500009];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, o;
cin >> n >> m >> o;
for(int i=0;i<n;i++) {
cin >> tab[i].st >> tab[i].nd;
}
sort(tab, tab+n);
vector<pii> v(m);
for(int i=0;i<m;i++) {
cin >> v[i].st >> v[i].nd;
}
sort(all(v));
vector<int> ans;
for(pii x:v) {
for(int i=0;i<n;i++) {
if(!vis[i]&&tab[i].nd>=x.nd&&tab[i].st<x.st) {
ans.pb(-(x.st-tab[i].st));
vis[i] = true;
break;
}
}
}
int res = 0;
sort(all(ans));
for(int i=0;i<min(sz(ans), o);i++) {
res -= ans[i];
}
cout << res << "\n";
}
# | 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... |