답안 #373836

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373836 2021-03-05T21:42:54 Z guka415 Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 141740 KB
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>

using namespace std;
typedef pair<int, int> pii;

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

int main() {
	int xp, yp, ret = 0, mx = -2e9;
	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]);
	mny[n - 1] = p[n - 1][1];
	for (int i = n - 2; i >= 0; i--)
		mny[i] = (mny[i + 1] > p[i][1] ? p[i][1] : mny[i + 1]);
	for (int i = 0; i < n; i++) {
		bool yes = 1;
		if (i && mxx[i - 1] >= p[i][0])
			yes = 0;
		if (i != n - 1 && mny[i + 1] <= p[i][1])
			yes = 0;
		ret += yes;
	}
	printf("%d", ret);
	return 0;
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:15:23: warning: unused variable 'mx' [-Wunused-variable]
   15 |  int xp, yp, ret = 0, mx = -2e9;
      |                       ^~
lightningrod.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
lightningrod.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |   scanf("%d %d", &xp, &yp);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2087 ms 141740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 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 364 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 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 364 KB Output is correct
14 Correct 50 ms 3272 KB Output is correct
15 Correct 54 ms 3436 KB Output is correct
16 Correct 46 ms 3180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2093 ms 139216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2087 ms 141740 KB Time limit exceeded
2 Halted 0 ms 0 KB -