답안 #548758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548758 2022-04-14T11:29:07 Z usukhbaatar Lightning Rod (NOI18_lightningrod) C++14
100 / 100
745 ms 79688 KB
#include <stack>
#include <cstdio>

using namespace std;

stack<pair<int, int>> s;

void fastscan(int &a) {
    a = 0;
    char c = getchar();
    for (; (c>47 && c<58); c=getchar())
        a = a *10 + c - 48;
}

int main() {
	int n, x, y;
	scanf("%d\n", &n);
	for (int i = 0; i < n; i++) {
		fastscan(x); fastscan(y);
		int l = x - y;
		int r = x + y;
		if (!s.empty()) {
			if (s.top().first <= l && r <= s.top().second)
				continue;
		}
		while (!s.empty() && l <= s.top().first && s.top().second <= r) s.pop();
		s.push({l, r});
	}
	printf("%d\n", s.size());
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:29: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=]
   29 |  printf("%d\n", s.size());
      |          ~^     ~~~~~~~~
      |           |           |
      |           int         std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
lightningrod.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d\n", &n);
      |  ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 465 ms 79688 KB Output is correct
2 Correct 531 ms 79496 KB Output is correct
3 Correct 488 ms 77304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 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 1 ms 212 KB Output is correct
11 Correct 0 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 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 1 ms 212 KB Output is correct
11 Correct 0 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 18 ms 284 KB Output is correct
15 Correct 18 ms 284 KB Output is correct
16 Correct 14 ms 904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 482 ms 51256 KB Output is correct
2 Correct 509 ms 52572 KB Output is correct
3 Correct 502 ms 50952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 465 ms 79688 KB Output is correct
2 Correct 531 ms 79496 KB Output is correct
3 Correct 488 ms 77304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 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 1 ms 212 KB Output is correct
14 Correct 0 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 18 ms 284 KB Output is correct
18 Correct 18 ms 284 KB Output is correct
19 Correct 14 ms 904 KB Output is correct
20 Correct 482 ms 51256 KB Output is correct
21 Correct 509 ms 52572 KB Output is correct
22 Correct 502 ms 50952 KB Output is correct
23 Correct 745 ms 2148 KB Output is correct
24 Correct 642 ms 2844 KB Output is correct
25 Correct 623 ms 26304 KB Output is correct