Submission #548750

# Submission time Handle Problem Language Result Execution time Memory
548750 2022-04-14T11:25:14 Z usukhbaatar Lightning Rod (NOI18_lightningrod) C++14
70 / 100
2000 ms 102632 KB
#include <stack>
#include <cstdio>

using namespace std;

stack<pair<int, int>> s;

int main() {
	int n, x, y;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &x, &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:22: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=]
   22 |  printf("%d\n", s.size());
      |          ~^     ~~~~~~~~
      |           |           |
      |           int         std::stack<std::pair<int, int> >::size_type {aka long unsigned int}
      |          %ld
lightningrod.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d%d", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1636 ms 102632 KB Output is correct
2 Correct 1717 ms 82132 KB Output is correct
3 Correct 1730 ms 78528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 284 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 284 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 284 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 2 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 47 ms 1036 KB Output is correct
15 Correct 46 ms 1004 KB Output is correct
16 Correct 42 ms 1636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 50468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1636 ms 102632 KB Output is correct
2 Correct 1717 ms 82132 KB Output is correct
3 Correct 1730 ms 78528 KB Output is correct
4 Correct 1 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 1 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 1 ms 284 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 300 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 47 ms 1036 KB Output is correct
18 Correct 46 ms 1004 KB Output is correct
19 Correct 42 ms 1636 KB Output is correct
20 Execution timed out 2041 ms 50468 KB Time limit exceeded
21 Halted 0 ms 0 KB -