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 n, x, y, h;
stack<pair<int, int>> s;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
vector<pair<int, int>> v(n);
for (auto &[x, y]:v) cin>>x>>y;
sort(v.begin(), v.end());
for (auto [x, y]:v)
{
if (s.empty())
{
s.push({x, y});
continue;
}
if (s.top().second-y>=x-s.top().first) continue;
while (!s.empty()&&y-s.top().second>=x-s.top().first) s.pop();
s.push({x, y});
}
cout<<s.size();
}
# | 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... |