Submission #373840

# Submission time Handle Problem Language Result Execution time Memory
373840 2021-03-05T21:49:30 Z guka415 Lightning Rod (NOI18_lightningrod) C
Compilation error
0 ms 0 KB
#include <stdio.h>

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.c:6:5: error: variably modified 'p' at file scope
    6 | int p[sz][2];
      |     ^
lightningrod.c:7:5: error: variably modified 'mxx' at file scope
    7 | int mxx[sz];
      |     ^~~
lightningrod.c: In function 'main':
lightningrod.c:11:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
lightningrod.c:13:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf("%d %d", &xp, &yp);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~