#include <bits/stdc++.h>
using namespace std;
inline void read(int& x) {
x = 0;
char ch = getchar_unlocked();
while (ch&16){
x = (x << 3) + (x << 1) + (ch&15);
ch = getchar_unlocked();
}
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
76360 KB |
Output is correct |
2 |
Correct |
208 ms |
76212 KB |
Output is correct |
3 |
Correct |
186 ms |
74156 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 |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 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 |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 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 |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 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 |
308 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 |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 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 |
308 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
9 ms |
588 KB |
Output is correct |
15 |
Correct |
9 ms |
752 KB |
Output is correct |
16 |
Correct |
8 ms |
1284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
198 ms |
49428 KB |
Output is correct |
2 |
Correct |
203 ms |
49300 KB |
Output is correct |
3 |
Correct |
197 ms |
48148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
201 ms |
76360 KB |
Output is correct |
2 |
Correct |
208 ms |
76212 KB |
Output is correct |
3 |
Correct |
186 ms |
74156 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 |
296 KB |
Output is correct |
8 |
Correct |
0 ms |
340 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 |
308 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
9 ms |
588 KB |
Output is correct |
18 |
Correct |
9 ms |
752 KB |
Output is correct |
19 |
Correct |
8 ms |
1284 KB |
Output is correct |
20 |
Correct |
198 ms |
49428 KB |
Output is correct |
21 |
Correct |
203 ms |
49300 KB |
Output is correct |
22 |
Correct |
197 ms |
48148 KB |
Output is correct |
23 |
Correct |
356 ms |
588 KB |
Output is correct |
24 |
Correct |
314 ms |
404 KB |
Output is correct |
25 |
Correct |
282 ms |
3000 KB |
Output is correct |