Submission #94543

#TimeUsernameProblemLanguageResultExecution timeMemory
94543FutymyCloneLightning Rod (NOI18_lightningrod)C++14
80 / 100
2013 ms192852 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...