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 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] - buttons);
sort(plots,plots+buttons);
//for (int i =0;i<buttons;i++) cout << plots[i].f << " " << plots[i].s << "\n";
vector <int> v;
for (int i =0;i<buttons;i++) {
int p = -plots[i].s;
if (v.empty() or v.back() < p) v.push_back(p);
else {
int pos = lower_bound(v.begin(),v.end(),p) - v.begin();
v[pos] = p;
}
}
cout << v.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... |