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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, n; cin >> N >> n;
vector<pair<int, int>> v(n);
for(int i = 0; i < n; i++) cin >> v[i].f;
for(int i = 0; i < n; i++) cin >> v[i].sc;
sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){
return make_pair(a.f-a.sc, a.f+a.sc) > make_pair(b.f-b.sc, b.f+b.sc);
});
vector<int> o(n);
for(int i = 0; i < n; i++) o[i] = i;
sort(o.begin(), o.end(), [&](int a, int b){
return make_pair(v[a].f+v[a].sc, -a) > make_pair(v[b].f+v[b].sc, -b);
});
set<int> s;
for(int i = 0; i < n; i++){
if(!s.empty() && *s.begin() < o[i]) s.erase(prev(s.lower_bound(o[i])));
s.insert(o[i]);
}
cout << s.size() << "\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... |