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;
typedef long long ll;
typedef long double ld;
struct Point
{
int x;
int y;
int inA;
};
bool cmp1(Point v, Point b)
{
return v.y > b.y;
}
bool cmp2(Point v, Point b)
{
return v.x < b.x;
}
const int N = (int)1e7 + 7;
int n;
Point a[N];
Point v[N];
bool viz[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
{
cin >> v[i].x >> v[i].y;
}
sort(v + 1, v + n + 1, cmp1);
for(int i = 1; i <= n; i++)
{
v[i].inA = i;
a[i] = v[i];
}
sort(v + 1, v + n + 1, cmp2);
int r = 0;
for(int it = 1; it <= n; it++)
{
int i = v[it].inA;
if(viz[i] == 0)
{
r++;
for(int j = i; j >= 1; j--)
{
if(viz[j]) break;
int dif = abs(v[i].x - v[j].x);
if(dif > v[i].y - v[j].y)
{
break;
}
viz[j] = 1;
}
for(int j = i + 1; j <= n; j++)
{
if(viz[j]) break;
int dif = abs(v[i].x - v[j].x);
if(dif > v[i].y - v[j].y)
{
break;
}
viz[j] = 1;
}
}
}
cout << r << "\n";
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... |