結果

問題 No.27 板の準備
ユーザー mbanmban
提出日時 2017-05-08 22:52:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 5,000 ms
コード長 854 bytes
コンパイル時間 1,134 ms
コンパイル使用メモリ 69,528 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:40:52
合計ジャッジ時間 2,477 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int V0, V1, V2, V3;
int Cnt(int a, int b, int c);

int main() {
	cin >> V0 >> V1 >> V2 >> V3;
	int ans = 999999;
	for (int A = 1; A <= 30; A++) {
		for (int B = 1; B <= 30; B++) {
			for (int C = 1; C <= 30; C++) {
				ans = min(ans, Cnt(A, B, C));
			}
		}
	}
	cout << ans << endl;
}

int Cnt(int a, int b, int c) {
	int Check[31];
	for (int i = 0; i <= 30; i++) {
		Check[i] = 99999;
	}
	Check[0] = 0;
	for (int j = 0; j <= 30; j++) {
		for (int i = 0; i <= 30; i++) {
			if (i + a <= 30) {
				Check[i + a] = min(Check[i] + 1, Check[i + a]);
			}
			if (i + b <= 30) {
				Check[i + b] = min(Check[i] + 1, Check[i + b]);;
			}
			if (i + c <= 30) {
				Check[i + c] = min(Check[i] + 1, Check[i + c]);;
			}

		}
	}
	return Check[V0] + Check[V1] + Check[V2] + Check[V3];
}
0