結果

問題 No.27 板の準備
ユーザー ikdikd
提出日時 2016-07-22 13:52:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 590 ms / 5,000 ms
コード長 862 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 63,348 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 04:31:36
合計ジャッジ時間 12,460 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>


using namespace std;
const int L=30;
vector<int> v;

int func(int a, int b, int c, int l){
    int ret=1e8;
    for(int i=0; i<=L; i++){
        for(int j=0; j<=L; j++){
            for(int k=0; k<=L; k++){
                if(a*i+b*j+c*k==l) ret=min(ret, i+j+k);
            }
        }
    }
    return ret;
}

int solve(int a, int b, int c){
    int ret=0;
    for(int m=0; m<v.size(); m++){
        ret+=func(a, b, c, v[m]);
    }
    return ret;
}
int main(){
    for(int i=0; i<4; i++){
        int V;
        cin>> V;
        v.push_back(V);
    }

    int ans=1e9;
    for(int A=1; A<=L; A++){// lenth
        for(int B=A+1; B<=L; B++){
            for(int C=B+1; C<=L; C++){
                ans=min(ans, solve(A, B, C));
            }
        }
    }

    cout<< ans<< endl;
    
    return 0;
}
0