#include <bits/stdc++.h>
using namespace std;
inline void read(int& x) {
x = 0;
char ch = getchar();
while (ch&16){
x = (x << 3) + (x << 1) + (ch&15);
ch = getchar();
}
}
struct T
{
int x;
int y;
};
bool eat(T a, T b)
{
return a.x <= b.x && a.y <= b.y;
}
signed main()
{
int n;
read(n);
vector<T> stk;
stk.reserve(n);
for (int i = 1; i <= n; i++)
{
int x, y;
read(x);
read(y);
T cur = {-x - y, x - y};
if (stk.empty())
{
stk.push_back(cur);
}
else
{
if (eat(stk.back(), cur))
{
continue;
}
while (!stk.empty() && eat(cur, stk.back()))
{
stk.pop_back();
}
stk.push_back(cur);
}
}
cout << (int) stk.size() << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
402 ms |
76056 KB |
Output is correct |
2 |
Correct |
407 ms |
75936 KB |
Output is correct |
3 |
Correct |
397 ms |
73840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
0 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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
0 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 |
12 ms |
212 KB |
Output is correct |
15 |
Correct |
12 ms |
316 KB |
Output is correct |
16 |
Correct |
12 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
401 ms |
48956 KB |
Output is correct |
2 |
Correct |
390 ms |
49084 KB |
Output is correct |
3 |
Correct |
393 ms |
47708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
402 ms |
76056 KB |
Output is correct |
2 |
Correct |
407 ms |
75936 KB |
Output is correct |
3 |
Correct |
397 ms |
73840 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
0 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 |
12 ms |
212 KB |
Output is correct |
18 |
Correct |
12 ms |
316 KB |
Output is correct |
19 |
Correct |
12 ms |
848 KB |
Output is correct |
20 |
Correct |
401 ms |
48956 KB |
Output is correct |
21 |
Correct |
390 ms |
49084 KB |
Output is correct |
22 |
Correct |
393 ms |
47708 KB |
Output is correct |
23 |
Correct |
583 ms |
344 KB |
Output is correct |
24 |
Correct |
516 ms |
560 KB |
Output is correct |
25 |
Correct |
507 ms |
2944 KB |
Output is correct |