結果

問題 No.27 板の準備
ユーザー atn112323atn112323
提出日時 2016-05-06 19:17:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 775 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 59,584 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:28:42
合計ジャッジ時間 1,214 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>

using namespace std;

const int INF = 1000;

int V[4];

int num(int L, int A, int B, int C) {
	int res = INF;
	int nc = L / C;
	for (int c = nc; c >= 0; c--) {
		int nb = (L - C * c) / B;
		for (int b = nb; b >= 0; b--) {
			int rest = L - C * c - B * b;
			if (rest % A == 0) {
				res = min(res, c + b + rest / A);
			}
		}
	}
	return res;
}

int num(int A, int B, int C) {
	int res = 0;
	for (int i = 0; i < 4; i++) {
		res += num(V[i], A, B, C);
	}
	return res;
}

int main() {
	for (int i = 0; i < 4; i++) {
		cin >> V[i];
	}
	int mi = INF;
	for (int A = 1; A <= 30; A++) {
		for (int B = A + 1; B <= 30; B++) {
			for (int C = B + 1; C <= 30; C++) {
				mi = min(mi, num(A, B, C));
			}
		}
	}
	cout << mi << endl;
	return 0;
}
0