답안 #586485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586485 2022-06-30T10:33:25 Z M_W Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1937 ms 81128 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	stack<pair<int, int>> stk;
	scanf("%d", &N);
	while(N--){
		int x, y; scanf("%d %d", &x, &y);
		
		if(!stk.empty() && stk.top().second > y && x - stk.top().first <= stk.top().second - y) continue;
		
		while(!stk.empty()){
			auto [xx, yy] = stk.top();
			if(y > yy && x - xx <= y - yy) stk.pop();
			else break;
		}
		stk.push({x, y});
	}
	printf("%d", stk.size());
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:19: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=]
   19 |  printf("%d", stk.size());
      |          ~^   ~~~~~~~~~~
      |           |           |
      |           int         std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
lightningrod.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:8:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   int x, y; scanf("%d %d", &x, &y);
      |             ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1583 ms 81128 KB Output is correct
2 Correct 1564 ms 81104 KB Output is correct
3 Correct 1478 ms 78940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 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 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 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 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 1 ms 304 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 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 312 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 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 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 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 312 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 50 ms 3852 KB Output is correct
15 Correct 38 ms 3600 KB Output is correct
16 Correct 37 ms 3660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1544 ms 56016 KB Output is correct
2 Correct 1584 ms 55664 KB Output is correct
3 Correct 1718 ms 54392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1583 ms 81128 KB Output is correct
2 Correct 1564 ms 81104 KB Output is correct
3 Correct 1478 ms 78940 KB Output is correct
4 Correct 1 ms 304 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 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 312 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 50 ms 3852 KB Output is correct
18 Correct 38 ms 3600 KB Output is correct
19 Correct 37 ms 3660 KB Output is correct
20 Correct 1544 ms 56016 KB Output is correct
21 Correct 1584 ms 55664 KB Output is correct
22 Correct 1718 ms 54392 KB Output is correct
23 Correct 1937 ms 2944 KB Output is correct
24 Correct 1697 ms 6052 KB Output is correct
25 Correct 1636 ms 8656 KB Output is correct