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 int long long
#define ll long long int
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long int>
#define vvll vector<vector<long long int>>
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define mii map<int,int>
#define mll map<long long int, long long int>
#define mivi map<int,vector<int>>
#define f0r(i,n) for(int i=0;i<n;i++)
#define FOR(i,k,n) for(int i=k;i<n;i++)
using namespace std;
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
//ifstream cin(".in");
//ofstream cout(".out");
int n;
cin>>n;
vpii v(n);
set<int>s;
f0r(i,n){
int x,e;
cin>>x>>e;
v[i] = {e,x};
s.insert(x);
}
if(n <= 1000){
sort(v.begin(), v.end());
int ans = 0;
vb vis(n,false);
for(int i = n-1;i>=0;i--){
if(!vis[i]){
ans++;
vis[i] = 1;
for(int j = i-1; j>=0; j--){
if(!vis[j] && (v[i].first - v[j].first) >= abs(v[i].second - v[j].second)){
vis[j] = 1;
}
}
}
}
cout<<ans;
}
else cout<<s.size();
}
# | 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... |