답안 #586369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586369 2022-06-30T07:52:40 Z hibiki Lightning Rod (NOI18_lightningrod) C++11
100 / 100
1990 ms 79764 KB
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second

stack<pair<int,int> > s;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        int x, y;
        scanf("%d %d",&x,&y);
        while(!s.empty() && x - s.top().f <= abs(y - s.top().s) && y > s.top().s)
            s.pop();
        if(s.empty() || x - s.top().f > abs(y - s.top().s))
            s.push({x, y});
    }
    printf("%d\n",s.size());
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:23:14: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::stack<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wformat=]
   23 |     printf("%d\n",s.size());
      |             ~^
      |              |
      |              int
      |             %ld
lightningrod.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
lightningrod.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d %d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1741 ms 79764 KB Output is correct
2 Correct 1669 ms 79468 KB Output is correct
3 Correct 1740 ms 77308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 40 ms 292 KB Output is correct
15 Correct 37 ms 212 KB Output is correct
16 Correct 39 ms 924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1764 ms 51260 KB Output is correct
2 Correct 1710 ms 51204 KB Output is correct
3 Correct 1695 ms 50100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1741 ms 79764 KB Output is correct
2 Correct 1669 ms 79468 KB Output is correct
3 Correct 1740 ms 77308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 40 ms 292 KB Output is correct
18 Correct 37 ms 212 KB Output is correct
19 Correct 39 ms 924 KB Output is correct
20 Correct 1764 ms 51260 KB Output is correct
21 Correct 1710 ms 51204 KB Output is correct
22 Correct 1695 ms 50100 KB Output is correct
23 Correct 1990 ms 404 KB Output is correct
24 Correct 1818 ms 1772 KB Output is correct
25 Correct 1704 ms 4284 KB Output is correct