#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int
using namespace std;
const int MAXN = (int) 1e7 + 5;
int x[MAXN + 1], y[MAXN + 1];
int stk[MAXN + 1], sp[MAXN + 1];
inline int getnr() {
char ch = getchar_unlocked();
int ans = 0;
while(!isdigit(ch)) {
ch = getchar_unlocked();
}
while(isdigit(ch)) {
ans = ans * 10 + ch - '0';
ch = getchar_unlocked();
}
return ans;
}
int main() {
#ifdef HOME
ifstream cin("A.in");
ofstream cout("A.out");
#endif
int i, n;
//ios::sync_with_stdio(false);
//cin.tie(0), cout.tie(0);
n = getnr();
for(i = 1; i <= n; i++) {
x[i] = getnr();
y[i] = getnr();
}
stk[0] = -1;
int sz = 0;
for(i = 1; i <= n; i++) {
while(sz > 0 && x[i] - x[stk[sz]] <= y[i] - y[stk[sz]]) {
sz--;
}
sp[stk[sz] + 1]++;
stk[++sz] = i;
}
sz = 0, stk[0] = n + 1;
for(i = n; i >= 1; i--) {
while(sz > 0 && x[stk[sz]] - x[i] <= y[i] - y[stk[sz]]) {
sz--;
}
sp[stk[sz]]--;
stk[++sz] = i;
}
int ans = 0;
for(i = 1; i <= n; i++) {
sp[i] += sp[i - 1];
ans += (sp[i] == 1);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
566 ms |
183884 KB |
Output is correct |
2 |
Correct |
574 ms |
185076 KB |
Output is correct |
3 |
Correct |
551 ms |
181148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
26 ms |
6052 KB |
Output is correct |
15 |
Correct |
22 ms |
5984 KB |
Output is correct |
16 |
Correct |
19 ms |
5624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
581 ms |
172776 KB |
Output is correct |
2 |
Correct |
582 ms |
173300 KB |
Output is correct |
3 |
Correct |
570 ms |
166304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
566 ms |
183884 KB |
Output is correct |
2 |
Correct |
574 ms |
185076 KB |
Output is correct |
3 |
Correct |
551 ms |
181148 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
26 ms |
6052 KB |
Output is correct |
18 |
Correct |
22 ms |
5984 KB |
Output is correct |
19 |
Correct |
19 ms |
5624 KB |
Output is correct |
20 |
Correct |
581 ms |
172776 KB |
Output is correct |
21 |
Correct |
582 ms |
173300 KB |
Output is correct |
22 |
Correct |
570 ms |
166304 KB |
Output is correct |
23 |
Correct |
980 ms |
173272 KB |
Output is correct |
24 |
Correct |
946 ms |
260176 KB |
Output is correct |
25 |
Correct |
904 ms |
243916 KB |
Output is correct |