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;
bool isContain(pair<int, int> &a, pair<int, int> &b)
{
return (abs(a.first - b.first) <= a.second - b.second);
}
inline void read(int &x)
{
x = 0;
char ch = getchar_unlocked();
while (ch & 16)
{
x = (x << 3) + (x << 1) + (ch & 15);
ch = getchar_unlocked();
}
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n;
read(n);
stack<pair<int, int>> st;
for (int i = 1; i <= n; i++)
{
pair<int, int> tmp;
int x, y;
read(x), read(y);
tmp = {x, y};
while (!st.empty() and isContain(tmp, st.top()))
st.pop();
if (st.empty() or !isContain(st.top(), tmp))
st.push(tmp);
}
cout << st.size() << "\n";
}
# | 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... |