結果

問題 No.50 おもちゃ箱
ユーザー maimai
提出日時 2016-05-13 13:54:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 677 bytes
コンパイル時間 1,849 ms
コンパイル使用メモリ 166,592 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-04-15 15:29:22
合計ジャッジ時間 8,765 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 199 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int aa[100],bb[100];
int n,m;

int calc(int idx,vector<int> &weight){
    if (idx<0) {
        return 0;
    }
    int min=99,r;
    for (int i=0;i<m;i++){
        if (weight[i]+aa[idx]<=bb[i]){
            vector<int> v=weight;
            v[i]+=aa[idx];
            r = (weight[i]==0) + calc(idx-1,v);
            if (r<min) min=r;
        }
    }
    return min;
}

int main(){
	int i, j, k, l;

    cin >> n;
    for (i=0;i<n;i++)
        scanf("%d",aa+i);
    cin >> m;
    for (i=0;i<m;i++)
        scanf("%d",bb+i);
    
    vector<int> weight(m,0);
    i=calc(n-1,weight) ;
    cout <<(i>90?-1:i)<< endl;
    
	return 0;
}
0