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;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll N;
cin>>N;
pair<ll,ll> arr[N];
for(ll i = 0;i < N;i++){
cin>>arr[i].first>>arr[i].second;
}
if(N > 1000){
set<ll> s;
for(ll i = 0;i < N;i++){
s.insert(arr[i].first);
}
cout<<s.size()<<'\n';
}else{
ll mini = 1e18;
for(ll bitmask = 0;bitmask < (1ll<<N);bitmask++){
ll sum = 0;
bool done[N];
memset(done,0,sizeof(done));
for(ll i = 0;i < N;i++){
if(bitmask & (1ll<<i)){
done[i] = 1;
for(ll j = 0;j < N;j++){
if(abs(arr[i].first - arr[j].first) <= arr[i].second - arr[j].second){
done[j] = 1;
}
}
sum++;
}
}
bool ok = 1;
for(ll i = 0;i < N;i++){
if(!done[i]){
ok = 0;
}
}
if(ok){
mini = min(mini,sum);
}
}
cout<<mini<<'\n';
}
}
# | 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... |