#include<bits/stdc++.h>
using namespace std;
struct point
{
int x,y;
};
int n;
vector<point> vec;
stack<point> st;
int cnt = 0;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i=0;i<n;++i)
{
int a,b;
cin >> a >> b;
vec.push_back({a,b});
}
for(int i=0;i<n;++i)
{
while(!st.empty() && vec[i].y-st.top().y >= abs(vec[i].x-st.top().x)) st.pop();
if(st.empty() || !(st.top().y-vec[i].y >= abs(vec[i].x-st.top().x)))
{
// cout << "add " << vec[i].x << " " << vec[i].y << '\n';
st.push({vec[i].x,vec[i].y});
}
}
cout << st.size();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1568 ms |
155636 KB |
Output is correct |
2 |
Correct |
1527 ms |
155216 KB |
Output is correct |
3 |
Correct |
1411 ms |
150960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
34 ms |
2512 KB |
Output is correct |
15 |
Correct |
41 ms |
2472 KB |
Output is correct |
16 |
Correct |
34 ms |
2412 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1501 ms |
131868 KB |
Output is correct |
2 |
Correct |
1485 ms |
131800 KB |
Output is correct |
3 |
Correct |
1433 ms |
131924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1568 ms |
155636 KB |
Output is correct |
2 |
Correct |
1527 ms |
155216 KB |
Output is correct |
3 |
Correct |
1411 ms |
150960 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
34 ms |
2512 KB |
Output is correct |
18 |
Correct |
41 ms |
2472 KB |
Output is correct |
19 |
Correct |
34 ms |
2412 KB |
Output is correct |
20 |
Correct |
1501 ms |
131868 KB |
Output is correct |
21 |
Correct |
1485 ms |
131800 KB |
Output is correct |
22 |
Correct |
1433 ms |
131924 KB |
Output is correct |
23 |
Correct |
1729 ms |
132020 KB |
Output is correct |
24 |
Correct |
1661 ms |
131776 KB |
Output is correct |
25 |
Correct |
1593 ms |
131784 KB |
Output is correct |