Submission #743793

# Submission time Handle Problem Language Result Execution time Memory
743793 2023-05-18T02:08:56 Z vjudge1 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
424 ms 79824 KB
#include<bits/stdc++.h>

using namespace std;

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

inline void read(int &x)
{
    x = 0;
    char ch = getchar_unlocked();
    while (ch & 16)
    {
        x = (x << 3) + (x << 1) + (ch & 15);
        ch = getchar_unlocked();
    }
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    read(n);
    for(int i = 0; i<n; ++i){
        read(x); read(y);
        if(!s.empty() && abs(s.top().first-x)<=s.top().second-y){
            continue;
        }
        while(!s.empty() && abs(x-s.top().first)<=y-s.top().second) s.pop();
        s.push({x,y});
    }
    cout<<s.size();
}
# Verdict Execution time Memory Grader output
1 Correct 290 ms 79824 KB Output is correct
2 Correct 302 ms 79624 KB Output is correct
3 Correct 290 ms 77628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 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 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 12 ms 1996 KB Output is correct
15 Correct 11 ms 1816 KB Output is correct
16 Correct 10 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 51328 KB Output is correct
2 Correct 323 ms 52400 KB Output is correct
3 Correct 311 ms 50220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 290 ms 79824 KB Output is correct
2 Correct 302 ms 79624 KB Output is correct
3 Correct 290 ms 77628 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 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 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 12 ms 1996 KB Output is correct
18 Correct 11 ms 1816 KB Output is correct
19 Correct 10 ms 1868 KB Output is correct
20 Correct 344 ms 51328 KB Output is correct
21 Correct 323 ms 52400 KB Output is correct
22 Correct 311 ms 50220 KB Output is correct
23 Correct 424 ms 680 KB Output is correct
24 Correct 347 ms 656 KB Output is correct
25 Correct 359 ms 3676 KB Output is correct