結果

問題 No.27 板の準備
ユーザー ktgktg
提出日時 2016-05-05 21:36:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,630 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 73,244 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:28:35
合計ジャッジ時間 1,478 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//#include <bits/stdc++.h>
#include <assert.h>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <iterator>
using namespace std;

typedef signed long long ll;

#define pp(...) (void)printf(__VA_ARGS__)
#define For(x,to) for(x=0;x<(to);x++)
#define ForAuto(x,arr) for(auto& x:arr)
#define ForBeginEnd(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define All(a) (a.begin()),(a.end())
#define Zeros(a) memset(a,0,sizeof(a))
#define Minus(a) memset(a,0xff,sizeof(a))

#define PI 3.14159265
#define EPS (1e-10)
#define EPS_eq(a,b) (abs((a)-(b)) < EPS)

#pragma GCC diagnostic ignored "-Wconversion"

//#define int long long
#define INF 1000*1000

int dxy[] = {0, 1, 0, -1, 0};

typedef pair<int, int> P;

void pp_int(int x){ printf("%d\n", x); };

//-------------------------------------------------

int a,b,c;
int i,v[4], memo[200];

int rec(int t){
    if (t <= 0) return 0;
    if(memo[t]) return memo[t];
    int res = INF;
    if(a <= t) res = min(res, rec(t-a) + 1);
    if(b <= t) res = min(res, rec(t-b) + 1);
    if(c <= t) res = min(res, rec(t-c) + 1);
    return memo[t] = res;
}

signed main() {
    int mn = 0;
    For(i, 4){
        cin>>v[i];
        mn += v[i];
    }
    for(a=1;a<=31;a++){
        for(b=a+1;b<=31;b++){
            for(c=b+1;c<=31;c++){
                Zeros(memo);
                mn = min(mn, rec(v[0]) + rec(v[1]) + rec(v[2]) + rec(v[3]));
            }
        }
    }
    printf("%d\n", mn);
    return 0;
}
0