結果

問題 No.27 板の準備
ユーザー TwizzTwizz
提出日時 2017-05-20 10:24:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 696 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 145,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:41:07
合計ジャッジ時間 2,023 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
const ll mod = 10000000000;


int v[4];

int main() {
	cin >> v[0] >> v[1] >> v[2] >> v[3];
	int max = 31;
	int ans = 999;
	rep(i, 1, max)rep(j, i + 1, max)rep(k, j + 1, max) {
		vector<int> dp(max,999);
		dp[0] = 0;
		rep(l, 0, max-i) { dp[l + i] = min(dp[l + i], dp[l] + 1); }
		rep(l, 0, max-j) { dp[l + j] = min(dp[l + j], dp[l] + 1); }
		rep(l, 0, max-k) { dp[l + k] = min(dp[l + k], dp[l] + 1); }
		ans = min(ans, dp[v[0]] + dp[v[1]] + dp[v[2]] + dp[v[3]]);
	}
	print(ans);
	return 0;
}
0