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
#define in array<int, 2>
#define pb push_back
#define pob pop_back
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
const int INF = 1e17;
int LIS(vector<int> v)
{
int N = v.size();
vector<int> d(N+2, INF);
d[0] = -INF;
for(auto x: v)
{
int l = lower_bound(d.begin(), d.end(), x)-d.begin();
if((d[l-1] < x) && (x < d[l]))
d[l] = x;
}
int s = 0;
while(d[s] != INF)
s++;
return --s;
}
signed main()
{
fast();
int M, n; cin >> M >> n;
vector<in> ab(n);
for(int i = 0; i < n; i++)
{
int t; cin >> t;
ab[i] = {t, t};
}
for(int i = 0; i < n; i++)
{
int t; cin >> t;
ab[i][0]-=t; ab[i][1]+=t;
}
sort(ab.begin(), ab.end());
vector<int> v;
for(int i = 0; i < n; i++)
v.pb(ab[n-1-i][1]);
cout << LIS(v) << "\n";
return 0;
}
# | 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... |