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;
int readInt(){
int x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') ch = getchar();
while (ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar();
}
return x;
}
int main(){
int n = readInt();
stack<pair<int,int> > stk;
for(int i=1;i<=n;i++){
int x = readInt();
int y = readInt();
if(stk.empty()){
stk.push({x,y});
}
else{
while(!stk.empty()){
int xx = stk.top().first;
int yy = stk.top().second;
if(yy>y){
int dx = x-xx;
int dy = yy-y;
if(dy<dx){
stk.push({x,y});
}
break;
}
int dx = x-xx;
int dy = y-yy;
if(dy>=dx){
stk.pop();
}else{
stk.push({x,y});
break;
}
}
if(stk.empty()){
stk.push({x,y});
}
}
}
cout<<stk.size()<<endl;
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... |