提出 #69410391


ソースコード 拡げる

#include <stdio.h>

int A[22][1 << 22];

int main(void) {
	int N, K;
	int i, j;
	int U = 0;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	A[0][0] = K;
	for (i = 1; i <= N; i++) {
		for (j = 0; j < (1 << (i - 1)); j++) {
			A[i][j * 2] = A[i - 1][j] / 2;
			A[i][j * 2 + 1] = A[i - 1][j] - A[i][j * 2];
		}
	}
	for (i = 1; i <= N; i++) {
		int min = A[i][0], max = A[i][0];
		for (j = 1; j < (1 << i); j++) {
			if (A[i][j] < min) min = A[i][j];
			if (A[i][j] > max) max = A[i][j];
		}
		if (max - min > U) U = max - min;
	}
	printf("%d\n", U);
	for (i = 0; i < (1 << N); i++) {
		printf(" %d" + !i, A[N][i]);
	}
	putchar('\n');
	return 0;
}

提出情報

提出日時
問題 D - Least Unbalanced
ユーザ mikecat
言語 C (gcc 12.2.0)
得点 400
コード長 671 Byte
結果 AC
実行時間 62 ms
メモリ 12816 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 25
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 1760 KiB
00_sample_01.txt AC 1 ms 1764 KiB
01_random_00.txt AC 1 ms 1756 KiB
01_random_01.txt AC 1 ms 1768 KiB
01_random_02.txt AC 1 ms 1640 KiB
01_random_03.txt AC 1 ms 1652 KiB
01_random_04.txt AC 1 ms 1764 KiB
01_random_05.txt AC 1 ms 1660 KiB
01_random_06.txt AC 1 ms 1608 KiB
01_random_07.txt AC 1 ms 1632 KiB
01_random_08.txt AC 1 ms 1744 KiB
01_random_09.txt AC 1 ms 1632 KiB
01_random_10.txt AC 1 ms 1780 KiB
01_random_11.txt AC 1 ms 1816 KiB
01_random_12.txt AC 1 ms 1852 KiB
01_random_13.txt AC 2 ms 1784 KiB
01_random_14.txt AC 3 ms 2068 KiB
01_random_15.txt AC 5 ms 2292 KiB
01_random_16.txt AC 8 ms 2692 KiB
01_random_17.txt AC 15 ms 3784 KiB
01_random_18.txt AC 28 ms 6120 KiB
01_random_19.txt AC 62 ms 12816 KiB
01_random_20.txt AC 1 ms 1648 KiB
01_random_21.txt AC 4 ms 2176 KiB
01_random_22.txt AC 1 ms 1764 KiB