#include <bits/stdc++.h>
using namespace std;
bool isContain(pair<int, int> &a, pair<int, int> &b)
{
return (abs(a.first - b.first) <= a.second - b.second);
}
inline void read(int &x)
{
x = 0;
char ch = getchar_unlocked();
while (ch & 16)
{
x = (x << 3) + (x << 1) + (ch & 15);
ch = getchar_unlocked();
}
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n;
read(n);
stack<pair<int, int>> st;
for (int i = 1; i <= n; i++)
{
pair<int, int> tmp;
int x, y;
read(x), read(y);
tmp = {x, y};
while (!st.empty() and isContain(tmp, st.top()))
st.pop();
if (st.empty() or !isContain(st.top(), tmp))
st.push(tmp);
}
cout << st.size() << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
219 ms |
79684 KB |
Output is correct |
2 |
Correct |
230 ms |
79436 KB |
Output is correct |
3 |
Correct |
216 ms |
77448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 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 |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
9 ms |
212 KB |
Output is correct |
15 |
Correct |
8 ms |
212 KB |
Output is correct |
16 |
Correct |
8 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
234 ms |
51324 KB |
Output is correct |
2 |
Correct |
218 ms |
51328 KB |
Output is correct |
3 |
Correct |
217 ms |
49940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
219 ms |
79684 KB |
Output is correct |
2 |
Correct |
230 ms |
79436 KB |
Output is correct |
3 |
Correct |
216 ms |
77448 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 |
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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
9 ms |
212 KB |
Output is correct |
18 |
Correct |
8 ms |
212 KB |
Output is correct |
19 |
Correct |
8 ms |
980 KB |
Output is correct |
20 |
Correct |
234 ms |
51324 KB |
Output is correct |
21 |
Correct |
218 ms |
51328 KB |
Output is correct |
22 |
Correct |
217 ms |
49940 KB |
Output is correct |
23 |
Correct |
397 ms |
212 KB |
Output is correct |
24 |
Correct |
326 ms |
324 KB |
Output is correct |
25 |
Correct |
345 ms |
10336 KB |
Output is correct |