結果
| 問題 |
No.27 板の準備
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-27 21:29:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 1,055 bytes |
| コンパイル時間 | 980 ms |
| コンパイル使用メモリ | 67,840 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 12:48:42 |
| 合計ジャッジ時間 | 1,868 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include <iostream>
#include <algorithm>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
const int inf = 1e9+7;
int main() {
const int MAX = 30;
int x, y, z, w; cin >> x >> y >> z >> w;
ll ans = inf;
repeat (c,MAX+1) {
repeat (b,c) {
repeat_from (a,1,b) {
array<ll,MAX+1> dp; whole(fill, dp, inf);
dp[0] = 0;
repeat (i,MAX) {
if (i+a < MAX+1) setmin(dp[i+a], dp[i] + 1);
if (i+b < MAX+1) setmin(dp[i+b], dp[i] + 1);
if (i+c < MAX+1) setmin(dp[i+c], dp[i] + 1);
}
setmin(ans, dp[x] + dp[y] + dp[z] + dp[w]);
}
}
}
cout << ans << endl;
return 0;
}