#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e7 + 10;
int x[MXN], y[MXN];
int main()
{
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
stack<int> st;
for (int i = 1; i <= n; i++)
{
cin >> x[i] >> y[i];
while (!st.empty() and x[i] - x[st.top()] <= y[i] - y[st.top()])
st.pop();
if (st.empty() or !(x[i] - x[st.top()] <= y[st.top()] - y[i]))
st.push(i);
}
cout << st.size() << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1618 ms |
116428 KB |
Output is correct |
2 |
Correct |
1497 ms |
115948 KB |
Output is correct |
3 |
Correct |
1511 ms |
112864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 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 |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 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 |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 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 |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 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 |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
320 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
39 ms |
2596 KB |
Output is correct |
15 |
Correct |
42 ms |
2668 KB |
Output is correct |
16 |
Correct |
37 ms |
2892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1537 ms |
104200 KB |
Output is correct |
2 |
Correct |
1627 ms |
106140 KB |
Output is correct |
3 |
Correct |
1461 ms |
103360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1618 ms |
116428 KB |
Output is correct |
2 |
Correct |
1497 ms |
115948 KB |
Output is correct |
3 |
Correct |
1511 ms |
112864 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
39 ms |
2596 KB |
Output is correct |
18 |
Correct |
42 ms |
2668 KB |
Output is correct |
19 |
Correct |
37 ms |
2892 KB |
Output is correct |
20 |
Correct |
1537 ms |
104200 KB |
Output is correct |
21 |
Correct |
1627 ms |
106140 KB |
Output is correct |
22 |
Correct |
1461 ms |
103360 KB |
Output is correct |
23 |
Correct |
1951 ms |
72708 KB |
Output is correct |
24 |
Execution timed out |
2082 ms |
71888 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |