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>
#include <iomanip>
#define ll long long
//#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define str string
#define pii pair<int,int>
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define mii map<int,int>
#define mll map<ll,ll>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yess cout<<"Yes\n";
#define noo cout<<"No\n";
using namespace std;
#define maxn 1111111
#define mod 1000000007
int u[10000001];
void solve(){
int n;
cin>>n;
pair<int,int>a[n+3];
set<int>s;
for(int i=1;i<=n;i++){
cin>>a[i].ss>>a[i].ff;
s.insert(a[i].ss);
}
if(n>2000){
cout<<s.size();
return;
}
sort(a+1,a+1+n);
for(int i=n;i>=2;i--){
if(u[i]==1){
continue;
}
for(int j=i-1;j>=1;j--){
//cout<<(abs(a[i].ss-a[j].ss)<=a[i].ff-a[j].ff)<<" "<<a[i].ss<<" "<<a[j].ss<<" "<<a[i].ff<<" "<<a[j].ff<<"\n";
if(abs(a[i].ss-a[j].ss)<=a[i].ff-a[j].ff){
u[j]=1;
}
}
}
int ans=0;
for(int i=1;i<=n;i++){
ans+=(u[i]==0);
}
cout<<ans;
}
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//srand( time(0));
//freopen("sum.in", "r", stdin);
//freopen("sum.out", "w", stdout);
int tests=1;
//cin>>tests;
for(int i=1;i<=tests;i++){
//cout<<"Case "<<i<<": \n";
solve();
}
}
# | 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... |