Submission #94543

# Submission time Handle Problem Language Result Execution time Memory
94543 2019-01-20T07:33:57 Z FutymyClone Lightning Rod (NOI18_lightningrod) C++14
80 / 100
2000 ms 192852 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 1e7 + 5;

int n;
stack <pair <int, int> > st;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int x, y;
        scanf("%d %d", &x, &y);

        bool ok = true;
        while (!st.empty()) {
            if (x - st.top().first <= st.top().second - y) {
                ok = false;
                break;
            }

            if (x - st.top().first <= y - st.top().second) st.pop();
            else break;
        }

        if (ok) st.push({x, y});
    }

    printf("%d", (int)st.size());
    return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
lightningrod.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1895 ms 192852 KB Output is correct
2 Correct 1866 ms 192120 KB Output is correct
3 Correct 1828 ms 186988 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 256 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 380 KB Output is correct
7 Correct 2 ms 256 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 256 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 380 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 256 KB Output is correct
10 Correct 2 ms 256 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 256 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 380 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 256 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 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 256 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 380 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 256 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 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 52 ms 3996 KB Output is correct
15 Correct 50 ms 3676 KB Output is correct
16 Correct 47 ms 3852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1784 ms 147860 KB Output is correct
2 Correct 1825 ms 147896 KB Output is correct
3 Correct 1784 ms 144164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1895 ms 192852 KB Output is correct
2 Correct 1866 ms 192120 KB Output is correct
3 Correct 1828 ms 186988 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 256 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 380 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 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 52 ms 3996 KB Output is correct
18 Correct 50 ms 3676 KB Output is correct
19 Correct 47 ms 3852 KB Output is correct
20 Correct 1784 ms 147860 KB Output is correct
21 Correct 1825 ms 147896 KB Output is correct
22 Correct 1784 ms 144164 KB Output is correct
23 Execution timed out 2013 ms 147784 KB Time limit exceeded
24 Halted 0 ms 0 KB -