답안 #265313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
265313 2020-08-14T15:28:55 Z T0p_ Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 163824 KB
#include<bits/stdc++.h>
using namespace std;

stack<pair<int, int>> stk;

int main()
{
	int n;
	scanf(" %d",&n);
	while(n--)
	{
		int x, y;
		scanf(" %d %d",&x,&y);
		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:28: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=]
   28 |  printf("%d\n",stk.size());
      |          ~^    ~~~~~~~~~~
      |           |            |
      |           int          std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
lightningrod.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf(" %d",&n);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf(" %d %d",&x,&y);
      |   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 163824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 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 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 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 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 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 1 ms 324 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 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 1 ms 324 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 70 ms 3948 KB Output is correct
15 Correct 68 ms 3704 KB Output is correct
16 Correct 62 ms 3704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2057 ms 125784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 163824 KB Time limit exceeded
2 Halted 0 ms 0 KB -