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 <set>
#include <algorithm>
using namespace std;
struct PUS {
long long int x, y;
} a[500005];
bool cmp(PUS aa, PUS bb) {
if (aa.x + aa.y == bb.x + bb.y) return aa.x - aa.y < bb.x - bb.y;
return aa.x + aa.y < bb.x + bb.y;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
long long int n, m;
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> a[i].x;
}
for (int i = 1; i <= m; i++) {
cin >> a[i].y;
}
sort(a + 1, a + m + 1, cmp);
multiset<long long int> s;
for (int i = 1; i <= n; i++) {
auto h = s.upper_bound(a[i].x - a[i].y);
if (h != s.begin()) {
s.erase(prev(h));
}
s.insert(a[i].x - a[i].y);
}
cout << s.size();
}
# | 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... |