이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(NULL)->sync_with_stdio(false);
int n; cin >> n;
stack<pair<int,int>> s;
int a,b; cin >> a >> b;
s.push({a,b});
for(int ti=2 ; ti<=n ; ti++){
int a,b; cin >> a >> b;
bool bo=false;
while(!s.empty() && a-s.top().first<=b-s.top().second){
s.pop();
bo=true;
}
if(bo){
s.push({a,b});
continue;
}
if(abs(s.top().first-a)<=s.top().second-b){
continue;
}
s.push({a,b});
}
cout << s.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... |