結果
| 問題 |
No.27 板の準備
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2015-07-21 00:23:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 1,340 bytes |
| コンパイル時間 | 2,098 ms |
| コンパイル使用メモリ | 163,428 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 11:38:23 |
| 合計ジャッジ時間 | 2,612 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
class PreparePlate {
public:
void solve(void) {
vector<int> v(4);
REP(i, 4)
cin>>v[i];
sort(RANGE(v));
const ll inf = (1<<30);
// 30*29*28 = 24360 なんで
// 全探索でいけそう
ll minN = inf;
for (int a = 1; a <= 30; ++a)
for (int b = a+1; b <= 30; ++b)
for (int c = b+1; c <= 30; ++c)
{
vector<ll> dp(30+1, inf);
dp[0] = 0;
for (int i = 1; i <= 30; ++i)
{
int x[] = {a,b,c};
REP(j, 3) if (i >= x[j])
dp[i] = min(dp[i], dp[i-x[j]]+1);
}
ll n = 0;
REP(i,4)
n = min(n+dp[v[i]], inf);
minN = min(n, minN);
}
cout<<minN<<endl;
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new PreparePlate();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth