답안 #469975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469975 2021-09-02T13:29:32 Z rainboy Hokej (COCI17_hokej) C
60 / 120
206 ms 22724 KB
#include <stdio.h>

#define N	500000
#define M	500000

unsigned int X = 12345;

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

int aa[N], bb[N];

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 (aa[ii[j]] == aa[i_])
				j++;
			else if (aa[ii[j]] > aa[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 ii[N], ii_[M * 6];
	int n, m, h, i, j, k, ans;

	scanf("%d%d", &m, &n);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &aa[i], &bb[i]);
		ii[i] = i;
	}
	sort(ii, 0, n);
	ans = 0;
	for (i = 0, j = 0; i < n && j < m * 6; i++) {
		int i_ = ii[i];

		while (j < m * 6 && bb[i_]--)
			ii_[j++] = i_, ans += aa[i_];
	}
	printf("%d\n", ans);
	for (h = 0; h < 6; h++)
		printf("%d ", ii_[h * m + 0] + 1);
	printf("\n");
	k = 0;
	for (j = 1; j < m; j++)
		for (h = 0; h < 6; h++)
			if (ii_[h * m + j] != ii_[h * m + j - 1])
				k++;
	printf("%d\n", k);
	for (j = 1; j < m; j++)
		for (h = 0; h < 6; h++)
			if (ii_[h * m + j] != ii_[h * m + j - 1])
				printf("%d %d %d\n", j, ii_[h * m + j - 1] + 1, ii_[h * m + j] + 1);
	return 0;
}

Compilation message

hokej.c: In function 'main':
hokej.c:37:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  scanf("%d%d", &m, &n);
      |  ^~~~~~~~~~~~~~~~~~~~~
hokej.c:39:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%d%d", &aa[i], &bb[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Failed 22 ms 12528 KB the answer doesn't match with the value Z
4 Correct 1 ms 292 KB Output is correct
5 Correct 9 ms 5196 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Incorrect 5 ms 424 KB Output isn't correct
8 Incorrect 35 ms 3396 KB Output isn't correct
9 Incorrect 201 ms 22672 KB Output isn't correct
10 Incorrect 206 ms 22724 KB Output isn't correct