이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |