제출 #707724

#제출 시각아이디문제언어결과실행 시간메모리
707724rainboyJust Long Neckties (JOI20_ho_t1)C11
0 / 100
0 ms212 KiB
#include <stdio.h>

#define N	200000

int max(int a, int b) { return a > b ? a : b; }

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

int *xx;

void sort(int *ii, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (xx[ii[j]] == xx[i_])
				j++;
			else if (xx[ii[j]] < xx[i_]) {
				tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
			}
		sort(ii, l, i);
		l = k;
	}
}

int main() {
	static int aa[N + 1], bb[N], ii[N + 1], jj[N], pp[N + 1], qq[N + 1];
	int n, i, j;

	scanf("%d", &n);
	for (i = 0; i <= n; i++)
		scanf("%d", &aa[i]);
	for (j = 0; j < n; j++)
		scanf("%d", &bb[j]);
	for (i = 0; i <= n; i++)
		ii[i] = i;
	xx = aa, sort(ii, 0, n + 1);
	for (j = 0; j < n; j++)
		jj[j] = j;
	xx = bb, sort(jj, 0, n);
	pp[0] = 0;
	for (i = 0; i < n; i++)
		pp[i + 1] = max(pp[i], aa[ii[i]] - bb[jj[i]]);
	qq[n] = 0;
	for (j = n - 1; j >= 0; j--)
		qq[j] = max(qq[j + 1], aa[ii[j + 1]] - bb[jj[j]]);
	for (i = 0; i <= n; i++)
		printf("%d%c", max(pp[i], qq[i]), i < n ? ' ' : '\n');
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

ho_t1.c: In function 'main':
ho_t1.c:38:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
ho_t1.c:40:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
ho_t1.c:42:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%d", &bb[j]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...