結果

問題 No.27 板の準備
ユーザー bal4ubal4u
提出日時 2019-09-03 08:59:20
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 824 bytes
コンパイル時間 909 ms
コンパイル使用メモリ 29,208 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 21:47:53
合計ジャッジ時間 2,922 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: 27 板の準備
// 2019.9.3 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int v[4];
int dp[33];

int cmp(const void *u, const void *v) { return *(int *)u - *(int *)v; }
inline static void chmin(int *a, int b) { if (*a > b) *a = b; }

int check(int *a) {
	int i, j, s;
	memset(dp, 0x01, sizeof(dp)); dp[0] = 0;
	for (i = 1; i <= 3; i++) for (j = a[i]; j <= 30; j++) chmin(&dp[j], dp[j-a[i]]+1);
	s = 0; for (i = 0; i < 4; i++) s += dp[v[i]];
	return s;
}
		
int main()
{
	int i, t, a[4], ans;
	
	for (i = 0; i < 4; i++) scanf("%d", v+i);
	qsort(v, 4, sizeof(int), cmp);
	ans = 10000;
	for (a[1] = 1; a[1] <= v[0]; a[1]++)
		for (a[2] = a[1]+1; a[2] < v[3]; a[2]++)
			for (a[3] = a[2]+1; a[3] <= v[3]; a[3]++) {
				if ((t = check(a)) < ans) ans = t;
			}
	printf("%d\n", ans);
	return 0;
}
0