Submission #515960

#TimeUsernameProblemLanguageResultExecution timeMemory
515960JomnoiLightning Rod (NOI18_lightningrod)C++17
100 / 100
1891 ms79812 KiB
#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    stack <pair <int, int>> stk;
    for(int i = 1; i <= n; i++) {
        int x, y;
        scanf("%d %d", &x, &y);
        while(!stk.empty() and stk.top().first >= x - y) {
            stk.pop();
        }

        if(stk.empty() or x + y > stk.top().second) {
            stk.emplace(x - y, x + y);
        }
    }
    printf("%d", (int)stk.size());
    return 0;
}

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
lightningrod.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         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...