이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <stack>
#include <set>
typedef long long llong;
const int MAXN = 200000 + 10;
const int INF = 1e9;
struct Person
{
int x, e;
friend bool operator > (const Person &a, const Person &b)
{
return a.e > b.e;
}
};
int n;
Person p[MAXN];
bool taken[MAXN];
void solve()
{
int ans = 0;
std::sort(p + 1, p + 1 + n, std::greater <Person> ());
for (int i = 1 ; i <= n ; ++i)
{
bool thereIs = false;
for (int j = i - 1 ; j >= 1 ; --j)
{
if (taken[j] && p[j].e - p[i].e >= abs(p[i].x - p[j].x))
{
thereIs = true;
break;
}
}
if (!thereIs)
{
taken[i] = true;
ans++;
}
}
std::cout << ans << '\n';
}
void input()
{
std::cin >> n;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> p[i].x >> p[i].e;
}
}
void fastIOI()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIOI();
input();
solve();
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... |