Submission #155202

# Submission time Handle Problem Language Result Execution time Memory
155202 2019-09-27T06:08:00 Z dolphingarlic Lightning Rod (NOI18_lightningrod) C++14
100 / 100
538 ms 191836 KB
#include <bits/stdc++.h>
using namespace std;
stack<pair<int, int> > s;
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;
}

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, 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(make_pair(x, y));
    }
    printf("%d", (int)s.size());
}
# Verdict Execution time Memory Grader output
1 Correct 377 ms 79816 KB Output is correct
2 Correct 406 ms 191836 KB Output is correct
3 Correct 381 ms 186596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 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 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 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 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 13 ms 3828 KB Output is correct
15 Correct 12 ms 3704 KB Output is correct
16 Correct 12 ms 3704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 358 ms 51448 KB Output is correct
2 Correct 379 ms 147472 KB Output is correct
3 Correct 370 ms 143844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 377 ms 79816 KB Output is correct
2 Correct 406 ms 191836 KB Output is correct
3 Correct 381 ms 186596 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 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 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 13 ms 3828 KB Output is correct
18 Correct 12 ms 3704 KB Output is correct
19 Correct 12 ms 3704 KB Output is correct
20 Correct 358 ms 51448 KB Output is correct
21 Correct 379 ms 147472 KB Output is correct
22 Correct 370 ms 143844 KB Output is correct
23 Correct 538 ms 175348 KB Output is correct
24 Correct 457 ms 156792 KB Output is correct
25 Correct 495 ms 140264 KB Output is correct