#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 500010;
int n, buttons;
int T[maxn], A[maxn];
pi plots[maxn];
int32_t main() {
FAST
cin >> n >> buttons;
for (int i =0;i<buttons;i++) cin >> T[i];
for (int i =0;i<buttons;i++) cin >> A[i];
for (int i =0;i<buttons;i++) plots[i] = pi(T[i] + A[i], T[i] - A[i]);
sort(plots,plots+buttons);
vector <int> v;
for (int i =0;i<buttons;i++) {
if (v.empty() or v.back() < plots[i].s) v.push_back(plots[i].s);
else {
int pos = lower_bound(v.begin(),v.end(),plots[i].s) - v.begin();
v[pos] = plots[i].s;
}
}
cout << v.size() << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |