Submission #785524

# Submission time Handle Problem Language Result Execution time Memory
785524 2023-07-17T09:59:31 Z 12345678 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1501 ms 191652 KB
#include <bits/stdc++.h>

using namespace std;

int n, x, y, h;
stack<pair<int, int>> s;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++)
    {
        cin>>x>>y;
        if (s.empty())
        {
            s.push({x, y});
            continue;
        }
        if (s.top().second-y>=x-s.top().first) continue;
        while (!s.empty()&&y-s.top().second>=x-s.top().first) s.pop();
        s.push({x, y});
    }
    cout<<s.size();
}
# Verdict Execution time Memory Grader output
1 Correct 1206 ms 174440 KB Output is correct
2 Correct 1266 ms 191652 KB Output is correct
3 Correct 1206 ms 186528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 368 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 212 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 368 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 360 KB Output is correct
14 Correct 30 ms 3880 KB Output is correct
15 Correct 43 ms 3620 KB Output is correct
16 Correct 30 ms 3660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1266 ms 147424 KB Output is correct
2 Correct 1258 ms 147316 KB Output is correct
3 Correct 1228 ms 143852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1206 ms 174440 KB Output is correct
2 Correct 1266 ms 191652 KB Output is correct
3 Correct 1206 ms 186528 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 368 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 360 KB Output is correct
17 Correct 30 ms 3880 KB Output is correct
18 Correct 43 ms 3620 KB Output is correct
19 Correct 30 ms 3660 KB Output is correct
20 Correct 1266 ms 147424 KB Output is correct
21 Correct 1258 ms 147316 KB Output is correct
22 Correct 1228 ms 143852 KB Output is correct
23 Correct 1493 ms 175304 KB Output is correct
24 Correct 1501 ms 156484 KB Output is correct
25 Correct 1458 ms 139808 KB Output is correct