結果
問題 | No.27 板の準備 |
ユーザー |
![]() |
提出日時 | 2015-02-21 22:43:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 1,332 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 83,664 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 10:29:41 |
合計ジャッジ時間 | 1,508 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include<iostream> #include<sstream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<vector> #include<cmath> #include<set> #include<map> #include<stack> #include<queue> #include<numeric> #include<functional> #include<complex> using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++) #define SZ(x) (int)(x.size()) #define ALL(x) (x).begin(),(x).end() #define MP make_pair #define FOR_EACH(it,v) for(__typeof(v.begin()) it=v.begin(),it_end=v.end() ; it != it_end ; it++) typedef vector<int> VI; typedef vector<VI> VVI; int main() { VI V(4); FOR(i,4) cin>>V[i]; int maxV = *max_element(ALL(V)); int ans = 1<<28; for(int A=1;A<=maxV;A++){ for(int B=A;B<=maxV;B++){ for(int C=B;C<=maxV;C++){ VI dp(maxV+1); for(int i=1;i<=maxV;i++){ dp[i] = 1<<28; if(i - A >= 0) dp[i] = min(dp[i], dp[i-A] + 1); if(i - B >= 0) dp[i] = min(dp[i], dp[i-B] + 1); if(i - C >= 0) dp[i] = min(dp[i], dp[i-C] + 1); } int sub = 0 ; FOR(i,4) sub += dp[V[i]]; ans = min(ans, sub); } } } cout<<ans<<endl; return 0; }