Submission #733408

# Submission time Handle Problem Language Result Execution time Memory
733408 2023-04-30T16:35:22 Z rainboy 대표 선수 (KOI11_player) C
0 / 20
109 ms 5388 KB
#include <stdio.h>

#define N	1000
#define M	1000
#define INF	0x3f3f3f3f

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 aa[N * M];

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

		while (j < k)
			if (aa[hh[j]] == aa[h])
				j++;
			else if (aa[hh[j]] < aa[h]) {
				tmp = hh[i], hh[i] = hh[j], hh[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = hh[j], hh[j] = hh[k], hh[k] = tmp;
			}
		sort(hh, l, i);
		l = k;
	}
}

int main() {
	static int hh[N * M];
	int n, m, h, h_, i, j, a, ans;

	scanf("%d%d", &n, &m);
	for (h = 0; h < n * m; h++) {
		scanf("%d", &aa[h]);
		hh[h] = h;
	}
	sort(hh, 0, n * m);
	a = 0;
	for (i = 0; i < n; i++)
		a = max(a, aa[i * m + 0]);
	ans = INF;
	for (h = 0; h < n * m; h++) {
		h_ = hh[h], i = h_ / m, j = h_ % m;
		ans = min(ans, a - aa[h_]);
		if (j + 1 == m)
			break;
		a = max(a, aa[i * m + j + 1]);
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

player.c: In function 'main':
player.c:41:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
player.c:43:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d", &aa[h]);
      |   ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 5388 KB Output isn't correct
2 Halted 0 ms 0 KB -