#include <bits/stdc++.h>
using namespace std;
inline int readInt() {
int x = 0;
char ch = getchar_unlocked();
bool s = 1;
while (ch < '0' || ch > '9') {
if (ch == '-') {
s = 0;
ch = getchar_unlocked();
}
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return s ? x : -x;
}
stack<pair<int, int>> s;
int main() {
int n = readInt();
for (int i = 0; i < n; i++) {
int x = readInt();
int y = readInt();
bool add = 1;
while (s.size()) {
int tx = s.top().first;
int ty = s.top().second;
if (x - tx <= ty - y) {
add = 0;
break;
}
if (x - tx <= y - ty) {
s.pop();
} else {
break;
}
}
if (add) {
s.push({x, y});
}
}
cout << s.size();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
249 ms |
192648 KB |
Output is correct |
2 |
Correct |
263 ms |
191988 KB |
Output is correct |
3 |
Correct |
236 ms |
186868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
440 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
440 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 |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
440 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 |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
436 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
440 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 |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
436 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
468 KB |
Output is correct |
14 |
Correct |
9 ms |
3932 KB |
Output is correct |
15 |
Correct |
8 ms |
3668 KB |
Output is correct |
16 |
Correct |
7 ms |
3672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
248 ms |
147740 KB |
Output is correct |
2 |
Correct |
239 ms |
147640 KB |
Output is correct |
3 |
Correct |
245 ms |
144052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
249 ms |
192648 KB |
Output is correct |
2 |
Correct |
263 ms |
191988 KB |
Output is correct |
3 |
Correct |
236 ms |
186868 KB |
Output is correct |
4 |
Correct |
0 ms |
344 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 |
440 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
436 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
468 KB |
Output is correct |
17 |
Correct |
9 ms |
3932 KB |
Output is correct |
18 |
Correct |
8 ms |
3668 KB |
Output is correct |
19 |
Correct |
7 ms |
3672 KB |
Output is correct |
20 |
Correct |
248 ms |
147740 KB |
Output is correct |
21 |
Correct |
239 ms |
147640 KB |
Output is correct |
22 |
Correct |
245 ms |
144052 KB |
Output is correct |
23 |
Correct |
441 ms |
175872 KB |
Output is correct |
24 |
Correct |
372 ms |
156788 KB |
Output is correct |
25 |
Correct |
328 ms |
140640 KB |
Output is correct |