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;
vector<pair<int, int>> v;
bool sorted(const pair<int, int> &a, const pair<int, int> &b)
{
if (a.second == b.second)
return a.first > b.first;
return a.second > b.second;
}
bool check(int x1, int x2, int y1, int y2)
{
return abs(x1 - x2) <= y1 - y2;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
unordered_map<int, int> ma;
int n, a, b;
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a >> b;
v.push_back({a, b});
ma[i - 1] = -1;
}
long long sum = n;
sort(v.begin(), v.end(), sorted);
for (int i = 0; i < v.size(); ++i)
{
for (int j = 0; j < v.size(); ++j)
{
if (ma[j] == -1 && i != j && check(v[i].first, v[j].first, v[i].second, v[j].second))
{
sum--;
ma[j] = i;
}
}
}
cout << sum;
}
Compilation message (stderr)
lightningrod.cpp: In function 'int main()':
lightningrod.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for (int i = 0; i < v.size(); ++i)
| ~~^~~~~~~~~~
lightningrod.cpp:35:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int j = 0; j < v.size(); ++j)
| ~~^~~~~~~~~~
# | 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... |