結果

問題 No.27 板の準備
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-19 12:38:32
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 899 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 144,364 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 02:12:30
合計ジャッジ時間 2,297 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>

using namespace std;

int solve(int i, int j, int k, int a){
    int mi = 100, b;
    for (int n=0; n<=30; n++){
        for (int m=0; m<=30; m++){
            b = a;
            b -= n*i+m*j;
            if (b >= 0 && b % k == 0) mi = min(n+m+b/k, mi);
        }
    }

    return mi;
}

int main(){

    int ans=1e9, tot;
    vector<int> a(4);
    for (int i=0; i<4; i++) cin >> a[i];

    for (int i=1; i<=30; i++){
        for (int j=i+1; j<=30; j++){
            for (int k=j+1; k<=30; k++){
                tot = 0;
                for (int l=0; l<4; l++) tot += solve(i, j, k, a[l]);
                ans = min(tot, ans);
            }
        }
    }

    cout << ans << endl;

    return 0;
}
0