結果

問題 No.617 Nafmo、買い出しに行く
ユーザー nebukuro09nebukuro09
提出日時 2017-12-18 10:59:02
言語 Bash
(Bash 5.1.16)
結果
TLE  
実行時間 -
コード長 340 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 5,304 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-22 05:21:09
合計ジャッジ時間 4,377 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
7,544 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 243 ms
4,376 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

read n k
a=()
for ((i=0; i<$n; i++))
do
    read a[i]
done

ans=0

for ((mask=0; mask<$((1<<n)); mask++))
do
    tmp=0
    for ((i=0; i<$n; i++))
    do
        if [ $((mask & (1<<i))) != 0 ]; then
            tmp=$((tmp+a[i]))
        fi
    done
    if [ $(((tmp <= k) && (ans < tmp))) == 1 ]; then
        ans=$tmp
    fi
done

echo $ans
0