답안 #425457

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
425457 2021-06-13T04:02:12 Z errorgorn Lightning Rod (NOI18_lightningrod) C++17
100 / 100
794 ms 192252 KB
#include <bits/stdc++.h>
#include <cstdio>
#include <stack>
using namespace std;
inline void read(int& x) {
    x = 0;
    char ch = getchar_unlocked();
    while (ch&16){ //this will break when ‘\n’ or ‘ ‘ is encountered
		x = (x << 3) + (x << 1) + (ch&15);
		ch = getchar_unlocked();
	}
}

int x,y;
typedef pair<int,int> ii;
stack<ii> s;
int main(){
    int N;
	read(N);
    read(x),read(y);
	s.push(ii(x,y));
	for(int i = 1; i < N; i++) {
		read(x),read(y);
		if (x-s.top().first>s.top().second-y){
            while (!s.empty() && x-s.top().first<=y-s.top().second){
                s.pop();
            }
            s.push(ii (x,y));
		}
	}
	printf("%d",s.size());
	return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:31:11: 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=]
   31 |  printf("%d",s.size());
      |          ~^  ~~~~~~~~
      |           |        |
      |           int      std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
# 결과 실행 시간 메모리 Grader output
1 Correct 546 ms 192252 KB Output is correct
2 Correct 524 ms 191868 KB Output is correct
3 Correct 559 ms 186812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 13 ms 3780 KB Output is correct
15 Correct 13 ms 3660 KB Output is correct
16 Correct 14 ms 3700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 495 ms 147456 KB Output is correct
2 Correct 514 ms 147372 KB Output is correct
3 Correct 573 ms 143788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 546 ms 192252 KB Output is correct
2 Correct 524 ms 191868 KB Output is correct
3 Correct 559 ms 186812 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 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 292 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 13 ms 3780 KB Output is correct
18 Correct 13 ms 3660 KB Output is correct
19 Correct 14 ms 3700 KB Output is correct
20 Correct 495 ms 147456 KB Output is correct
21 Correct 514 ms 147372 KB Output is correct
22 Correct 573 ms 143788 KB Output is correct
23 Correct 794 ms 175300 KB Output is correct
24 Correct 724 ms 156612 KB Output is correct
25 Correct 656 ms 139996 KB Output is correct