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;
int main()
{
int n;
cin >> n;
vector<pair<int,int>> xe;
set<pair<int,int>> cc;
for(int i = 0;i < n;++i)
{
int a,b;
cin >> a >> b;
//cin >> xe[i].first >> xe[i].second;
if(cc.find({a,b}) == cc.end())
{
xe.push_back({a,b});
cc.insert({a,b});
}
}
sort(xe.begin(),xe.end());
int tmx = -2e9;
n = xe.size();
bool x[n];
for(int i = 0;i < n;++i)
x[i] = 0;
for(int i = 0;i < n;++i)
{
if(xe[i].first + xe[i].second <= tmx)
{
x[i] = 1;
}
tmx = max(tmx,xe[i].first+xe[i].second);
}
int tmn = 2e9;
for(int i = n-1;i >= 0;--i)
{
if(xe[i].first - xe[i].second >= tmn)
{
x[i] = 1;
}
tmn = min(tmn,xe[i].first - xe[i].second);
}
int ans = 0;
for(int j = 0;j < n;++j)
{
ans += 1-x[j];
}
cout << ans;
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... |