이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
llo n,m;
llo ans[1000001];
llo aa[1000001];
llo bb[1000001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>m>>n;
vector<pair<pair<llo,llo>,llo>> ss;
for(int i=0;i<n;i++){
cin>>bb[i];
}
for(int i=0;i<n;i++){
cin>>aa[i];
}
for(llo i=0;i<n;i++){
// cin>>aa[i]>>bb[i];
// cout<<aa[i]+bb[i]<<","<<bb[i]-aa[i]<<endl;
ss.pb({{aa[i]+bb[i],bb[i]-aa[i]},i});
}
sort(ss.begin(),ss.end());
llo ind=1;
set<pair<llo,llo>> xx;
for(auto j:ss){
auto k=xx.upper_bound({j.a.b+1,-1});
if(k==xx.begin()){
ans[j.b]=ind;
ind++;
}
else{
k--;
//cout<<j.b<<":"<<(*k).b<<endl;
ans[j.b]=ans[(*k).b];
xx.erase(k);
}
xx.insert({j.a.b,j.b});
}
cout<<ind-1<<endl;
/*for(llo i=0;i<n;i++){
cout<<aa[i]<<" "<<bb[i]<<" "<<ans[i]<<endl;
}*/
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... |