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;
using pi = pair<int,int>;
int xl,yl,x,y;
int ans=0,n;
stack<pi> s;
bool v=true;
int main()
{
cin.tie(nullptr)->sync_with_stdio(false);
cin >> n;
for(int i=0;i<n;i++){
cin >> x >> y;
if(s.empty()){s.push({x,y});}
v=true;
while(true){
if(s.empty())break;
auto[xl,yl]=s.top();
if(x-xl <= yl-y){//negative gradient = nom'd
v=false;
break;
}
if(x-xl <= y-yl){
s.pop();
}else{
break;
}
}
if(v)s.push({x,y});
}
cout << s.size();
return 0;
}
/*
3
0 0
1 1
2 3
*/
# | 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... |