답안 #707723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707723 2023-03-09T21:11:05 Z rainboy Just Long Neckties (JOI20_ho_t1) C
0 / 100
0 ms 212 KB
#include <stdio.h>

#define N	200000

int min(int a, int b) { return a < b ? a : b; }
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 ", max(pp[i], qq[i]));
	printf("\n");
	return 0;
}

Compilation message

ho_t1.c: In function 'main':
ho_t1.c:39:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
ho_t1.c:41:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
ho_t1.c:43:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d", &bb[j]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -