답안 #265322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
265322 2020-08-14T15:47:46 Z T0p_ Lightning Rod (NOI18_lightningrod) C++14
100 / 100
714 ms 192028 KB
#include<bits/stdc++.h>
using namespace std;
 
stack<pair<int, int>> stk;

int fi()
{
	int ret = 0;
	while(true)
	{
		char c = getchar_unlocked();
		if('0' <= c && c <= '9')
		{
			ret *= 10;
			ret += (c-'0');
		}
		else return ret;
	}

}

int main()
{
	int n = fi();
	while(n--)
	{
		int x = fi(), y = fi();
		if(stk.empty()) stk.push({x, y});
		else
		{
			int h = stk.top().second - x + stk.top().first;
			if(h >= y) continue ;
			while(!stk.empty())
			{
				int h = y - x + stk.top().first;
				if(h >= stk.top().second) stk.pop();
				else break ;
			}
			stk.push({x, y});
		}
	}
	printf("%d\n",stk.size());
	return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:42: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=]
   42 |  printf("%d\n",stk.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 90524 KB Output is correct
2 Correct 536 ms 192028 KB Output is correct
3 Correct 507 ms 187032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 13 ms 256 KB Output is correct
15 Correct 12 ms 256 KB Output is correct
16 Correct 13 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 471 ms 58108 KB Output is correct
2 Correct 497 ms 147704 KB Output is correct
3 Correct 509 ms 144056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 90524 KB Output is correct
2 Correct 536 ms 192028 KB Output is correct
3 Correct 507 ms 187032 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 13 ms 256 KB Output is correct
18 Correct 12 ms 256 KB Output is correct
19 Correct 13 ms 1024 KB Output is correct
20 Correct 471 ms 58108 KB Output is correct
21 Correct 497 ms 147704 KB Output is correct
22 Correct 509 ms 144056 KB Output is correct
23 Correct 714 ms 175672 KB Output is correct
24 Correct 702 ms 157100 KB Output is correct
25 Correct 592 ms 140664 KB Output is correct