結果

問題 No.27 板の準備
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2014-10-05 22:37:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 1,262 bytes
コンパイル時間 653 ms
コンパイル使用メモリ 85,648 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 03:23:54
合計ジャッジ時間 3,644 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/*
1.txt
1 1 1 1
4
2.txt
2 2 3 4
4
3.txt
3 3 3 29
4
4.txt
4 4 8 8
4
5.txt
5 17 22 24
5
6.txt
14 16 17 20
7
7.txt
20 23 24 25
7
8.txt
13 21 27 29
7
9.txt
27 28 29 30
6
10.txt
18 24 25 29
9
*/

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
 
int main(){
  int v[4];
  cin >> v[0] >> v[1] >> v[2] >> v[3];
  int mn = 100000;
  rep(a,1,31){
    rep(b,1,31){
      rep(c,1,31){
        int dp[10000];
        rep(i,0,10000)dp[i]=10000;
        dp[0] = 0;
        rep(i,0,31){
          dp[i+a]=min(dp[i+a],dp[i]+1);
          dp[i+b]=min(dp[i+b],dp[i]+1);
          dp[i+c]=min(dp[i+c],dp[i]+1);
        }
        mn = min(mn,dp[v[0]]+dp[v[1]]+dp[v[2]]+dp[v[3]]);
      }
    }
  }
  cout << mn << endl;
  return 0;
}
0