답안 #515960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
515960 2022-01-20T08:11:12 Z Jomnoi Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1891 ms 79812 KB
#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

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);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1530 ms 79812 KB Output is correct
2 Correct 1580 ms 79644 KB Output is correct
3 Correct 1489 ms 77428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 54 ms 204 KB Output is correct
15 Correct 44 ms 288 KB Output is correct
16 Correct 36 ms 912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1710 ms 51416 KB Output is correct
2 Correct 1633 ms 51400 KB Output is correct
3 Correct 1587 ms 50116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1530 ms 79812 KB Output is correct
2 Correct 1580 ms 79644 KB Output is correct
3 Correct 1489 ms 77428 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 54 ms 204 KB Output is correct
18 Correct 44 ms 288 KB Output is correct
19 Correct 36 ms 912 KB Output is correct
20 Correct 1710 ms 51416 KB Output is correct
21 Correct 1633 ms 51400 KB Output is correct
22 Correct 1587 ms 50116 KB Output is correct
23 Correct 1891 ms 524 KB Output is correct
24 Correct 1775 ms 672 KB Output is correct
25 Correct 1704 ms 3100 KB Output is correct