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;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
vector<pii> arr;
int main(){
cin>>n;
arr.resize(n);
priority_queue<pii> pq;
for(int i = 0; i < n; i++){
cin>>arr[i].first>>arr[i].second;
pq.push(mp(arr[i].second, i));
}
bool vis[n];
memset(vis, false, sizeof vis);
int ans = 0;
while(!pq.empty()){
pii here = pq.top();
pq.pop();
if(vis[here.second]) continue;
else{
ans++;
for(int i = here.second + 1; i < n; i++){
if(vis[i]) continue;
else if(abs(arr[here.second].first - arr[i].first) <= here.first - arr[i].second){
vis[i] = true;
}
else
continue;
}
for(int i = here.second-1; i >= 0; i--){
if(vis[i]) continue;
else if(abs(arr[here.second].first - arr[i].first) <= here.first - arr[i].second){
vis[i] = true;
}
else
continue;
}
}
}
cout<<ans<<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... |