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;
const int MXN = 1e7 + 10;
int x[MXN], y[MXN];
inline bool isContain(int i, int j)
{
return (abs(x[i] - x[j]) <= y[i] - y[j]);
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
stack<int> st;
for (int i = 1; i <= n; i++)
{
cin >> x[i] >> y[i];
while (!st.empty() and isContain(i, st.top()))
st.pop();
if (st.empty() or !isContain(st.top(), i))
st.push(i);
}
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... |