結果

問題 No.1463 Hungry Kanten
ユーザー maguroflymagurofly
提出日時 2021-04-02 21:36:58
言語 Ruby
(3.3.0)
結果
AC  
実行時間 897 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 11,416 KB
実行使用メモリ 47,080 KB
最終ジャッジ日時 2023-08-25 14:50:24
合計ジャッジ時間 5,495 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,176 KB
testcase_01 AC 74 ms
15,088 KB
testcase_02 AC 105 ms
16,308 KB
testcase_03 AC 736 ms
15,396 KB
testcase_04 AC 80 ms
15,100 KB
testcase_05 AC 897 ms
47,080 KB
testcase_06 AC 75 ms
15,340 KB
testcase_07 AC 75 ms
15,092 KB
testcase_08 AC 74 ms
15,220 KB
testcase_09 AC 76 ms
15,092 KB
testcase_10 AC 73 ms
15,128 KB
testcase_11 AC 75 ms
15,180 KB
testcase_12 AC 76 ms
15,344 KB
testcase_13 AC 73 ms
15,340 KB
testcase_14 AC 82 ms
15,392 KB
testcase_15 AC 86 ms
15,132 KB
testcase_16 AC 101 ms
16,228 KB
testcase_17 AC 133 ms
17,036 KB
testcase_18 AC 180 ms
16,148 KB
testcase_19 AC 388 ms
28,440 KB
testcase_20 AC 705 ms
31,972 KB
testcase_21 AC 73 ms
15,356 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "set"

N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
set = Set.new

(1 << N).times do |bits|
    sum = 0
    prod = 1
    count = 0
    N.times do |i|
        next if bits[i] == 0
        sum += A[i]
        prod *= A[i]
        count += 1
    end
    next if count < K
    set << sum << prod
end

puts set.size
0