結果
問題 | No.27 板の準備 |
ユーザー |
|
提出日時 | 2015-04-28 06:17:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 837 bytes |
コンパイル時間 | 1,255 ms |
コンパイル使用メモリ | 160,116 KB |
実行使用メモリ | 6,812 KB |
最終ジャッジ日時 | 2024-07-05 05:00:32 |
合計ジャッジ時間 | 2,018 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 1 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long Int; #define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i)) int dfs(int n, int B[3], int d, int s) { if (n == 0) return d; if (n < 0) return 999999; int res = 999999; if (s <= 0) res = min(res, dfs(n - B[0], B, d + 1, 0)); if (s <= 1) res = min(res, dfs(n - B[1], B, d + 1, 1)); if (s <= 2) res = min(res, dfs(n - B[2], B, d + 1, 2)); return res; } int check(int a[4], int B[3]) { int res = 0; REP(i, 4) res += dfs(a[i], B, 0, 0); return res; } int a[4]; int main() { REP(i, 4) cin >> a[i]; sort(a, a + 4); int best = 999999; for (int A = 1; A <= a[0]; A++) { for (int B = A + 1; B <= a[3]; B++) { for (int C = B + 1; C <= a[3]; C++) { int bs[] = { A, B, C }; int x = check(a, bs); if (best > x) best = x; } } } cout << best << endl; }