답안 #548756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548756 2022-04-14T11:28:28 Z usukhbaatar Lightning Rod (NOI18_lightningrod) C++14
0 / 100
416 ms 264 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);
	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);
      |  ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 408 ms 264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 416 ms 260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 408 ms 264 KB Output isn't correct
2 Halted 0 ms 0 KB -