結果

問題 No.27 板の準備
ユーザー data9824data9824
提出日時 2015-06-14 05:34:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,055 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 63,984 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 03:26:59
合計ジャッジ時間 1,288 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 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 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 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 3 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int main() {
	vector<int> v(4);
	for (size_t i = 0; i < v.size(); ++i) {
		cin >> v[i];
	}
	vector<int> count(30 + 30 + 1);
	int minCount = numeric_limits<int>::max();
	for (int a = 1; a <= 30; ++a) {
		for (int b = a + 1; b <= 30; ++b) {
			for (int c = b + 1; c <= 30; ++c) {
				int totalCount = 0;
				for (size_t i = 0; i < v.size(); ++i) {
					fill(count.begin(), count.end(), numeric_limits<int>::max());
					count[0] = 0;
					for (int k = 0; k < v[i]; ++k) {
						if (count[k] != numeric_limits<int>::max()) {
							count[k + a] = min(count[k + a], count[k] + 1);
							count[k + b] = min(count[k + b], count[k] + 1);
							count[k + c] = min(count[k + c], count[k] + 1);
						}
					}
					if (count[v[i]] == numeric_limits<int>::max()) {
						totalCount = numeric_limits<int>::max();
						break;
					}
					totalCount += count[v[i]];
				}
				minCount = min(minCount, totalCount);
			}
		}
	}
	cout << minCount << endl;
	return 0;
}
0