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;
stack<pair<int, int>> stk;
vector<pair<int, int>> temp;
int main() {
cin.tie(0)->sync_with_stdio(false);
//freopen("thunder.inp", "r", stdin);
//freopen("thunder.out", "w", stdout);
int n;
cin >> n;
for (int i=1; i<=n; i++) {
int x,y;
cin >> x >> y;
temp.push_back({x,y});
}
sort(temp.begin(), temp.end());
for (int i=0; i<n; i++) {
int x,y;
x=temp[i].first; y=temp[i].second;
if(stk.empty()) stk.push({x, y});
else
{
int h = stk.top().second - x + stk.top().first;
if(h >= y) continue ;
while(!stk.empty())
{
int h = y - x + stk.top().first;
if(h >= stk.top().second) stk.pop();
else break ;
}
stk.push({x, y});
}
}
cout << stk.size();
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |