#include <bits/stdc++.h>
using namespace std;
int TIME = clock();
#define file \
freopen("in.txt" , "r" , stdin); \
freopen("out.txt" , "w" , stdout);
void test_case () {
int n;
cin >> n;
stack <array <int , 2>> st;
auto check = [&](array<int , 2> se , array<int , 2> fi) -> bool {
return (abs(fi[0] - se[0]) <= fi[1] - se[1]);
};
for (int i = 0;i < n;i ++) {
int x , y;
cin >> x >> y;
array<int , 2> tmp = {x , y};
if (st.size() == 0) {
st.push(tmp);
continue;
}
if (check(tmp , st.top()) == true) {
continue;
}
while (st.size() > 0 && check(st.top() , tmp) == true) {
st.pop();
}
st.push({x , y});
}
cout << (int)st.size() << "\n";
}
int32_t main () {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
///// file
int t = 1;
// cin >> t;
while (t --) {
test_case();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1104 ms |
105700 KB |
Output is correct |
2 |
Correct |
1132 ms |
135916 KB |
Output is correct |
3 |
Correct |
1139 ms |
132472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
27 ms |
348 KB |
Output is correct |
15 |
Correct |
27 ms |
348 KB |
Output is correct |
16 |
Correct |
28 ms |
976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1135 ms |
71260 KB |
Output is correct |
2 |
Correct |
1115 ms |
51528 KB |
Output is correct |
3 |
Correct |
1069 ms |
50068 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1104 ms |
105700 KB |
Output is correct |
2 |
Correct |
1132 ms |
135916 KB |
Output is correct |
3 |
Correct |
1139 ms |
132472 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
27 ms |
348 KB |
Output is correct |
18 |
Correct |
27 ms |
348 KB |
Output is correct |
19 |
Correct |
28 ms |
976 KB |
Output is correct |
20 |
Correct |
1135 ms |
71260 KB |
Output is correct |
21 |
Correct |
1115 ms |
51528 KB |
Output is correct |
22 |
Correct |
1069 ms |
50068 KB |
Output is correct |
23 |
Correct |
1352 ms |
452 KB |
Output is correct |
24 |
Correct |
1224 ms |
624 KB |
Output is correct |
25 |
Correct |
1210 ms |
3040 KB |
Output is correct |