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;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
long long n,m;
cin>>n>>m;
long long t[m+5],a[m+5];
for(long long i=0;i<m;i++) cin>>t[i];
for(long long i=0;i<m;i++) cin>>a[i];
vector<pair<long long,long long>> v;
for(long long i=0;i<m;i++) v.push_back({t[i]+a[i],t[i]-a[i]});
sort(v.begin(),v.end(),[](pair<long long,long long> a,pair<long long,long long> b){
if(a.first==b.first) return a.second>b.second;
return a.first<b.first;
});
vector<long long> w;
for(long long i=0;i<m;i++){
long long pos=lower_bound(w.begin(),w.end(),v[i].second)-w.begin();
if(pos==w.size()) w.push_back(v[i].second);
else w[pos]=v[i].second;
}
cout<<w.size();
}
Compilation message (stderr)
Arcade.cpp: In function 'int main()':
Arcade.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(pos==w.size()) w.push_back(v[i].second);
~~~^~~~~~~~~~
# | 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... |