Submission #373838

# Submission time Handle Problem Language Result Execution time Memory
373838 2021-03-05T21:47:45 Z guka415 Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 117564 KB
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

using namespace std;

const int sz = 1e7 + 5;
int n;
int p[sz][2];
int mxx[sz];

int main() {
	int xp, yp, ret = 0, prvmny;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &xp, &yp);
		p[i][0] = xp + yp;
		p[i][1] = xp - yp;
	}
	mxx[0] = p[0][0];
	for (int i = 1; i < n; i++)
		mxx[i] = (mxx[i - 1] < p[i][0] ? p[i][0] : mxx[i - 1]);
	prvmny = p[n - 1][1];
	for (int i = n - 2; i >= 1; i--) {
		ret += (mxx[i - 1]<p[i][0] && prvmny>p[i][1]);
		prvmny = (prvmny > p[i][1] ? p[i][1] : prvmny);
	}
	ret += (prvmny > p[0][1]);
	ret += (mxx[n - 2] < p[n - 1][0]);
	printf("%d", ret);
	return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%d %d", &xp, &yp);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 74584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 0 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 52 ms 2540 KB Output is correct
15 Correct 53 ms 2668 KB Output is correct
16 Correct 44 ms 2540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 117564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 74584 KB Time limit exceeded
2 Halted 0 ms 0 KB -