結果

問題 No.27 板の準備
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-11 08:22:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 721 bytes
コンパイル時間 1,151 ms
コンパイル使用メモリ 145,020 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:20:18
合計ジャッジ時間 2,073 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++)
#define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++)
#define all(n) (n).begin(),(n).end()
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int,int> Pii;
typedef vector<Pii> VPii;

int main(){
	int v[4];
	rep(i,4) cin >> v[i];
	int ans = 100000000;
	REP(i,1,30){
		REP(j,1,30){
			REP(k,1,30){
				int dp[64] = {};
				fill(dp,dp+64,100000000);
				dp[0] = 0;
				rep(l,32) dp[l+i] = min(dp[l+i],dp[l]+1);
				rep(l,32) dp[l+j] = min(dp[l+j],dp[l]+1);
				rep(l,32) 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]]);
			}
		}
	}
	cout << ans << endl;
	
}
0