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 pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxn=5e5+10;
const ll inf=1e18;
const ll mod=1e9+7;
ll n,m,t[maxn],a[maxn],e[maxn];
pli b[maxn];
void solve()
{
cin >> m >> n;
for(int i=1;i<=n;i++) cin >> t[i];
for(int i=1;i<=n;i++) cin >> a[i];
for(int i=1;i<=n;i++)
{
b[i].fi=a[i]+t[i];
b[i].se=t[i]-a[i];
}
sort(b+1,b+n+1);
ll sz=0;
for(int i=1;i<=n;i++)
{
ll low=1,high=sz;
while(low<=high)
{
ll mid=low+high>>1;
if(e[mid]<=b[i].se) high=mid-1;
else low=mid+1;
}
if(low>sz) sz++;
e[low]=b[i].se;
}
cout << sz;
}
int main()
{
fastio
//freopen(TASKNAME".INP","r",stdin);
//freopen(TASKNAME".OUT","w",stdout);
solve();
}
Compilation message (stderr)
Arcade.cpp: In function 'void solve()':
Arcade.cpp:31:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
31 | ll mid=low+high>>1;
| ~~~^~~~~
# | 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... |