結果

問題 No.1463 Hungry Kanten
ユーザー simansiman
提出日時 2021-04-05 04:00:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 583 ms / 2,000 ms
コード長 256 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,576 KB
実行使用メモリ 50,628 KB
最終ジャッジ日時 2023-08-28 15:05:57
合計ジャッジ時間 4,367 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,108 KB
testcase_01 AC 74 ms
14,988 KB
testcase_02 AC 92 ms
16,356 KB
testcase_03 AC 452 ms
15,916 KB
testcase_04 AC 76 ms
15,080 KB
testcase_05 AC 583 ms
50,628 KB
testcase_06 AC 78 ms
15,212 KB
testcase_07 AC 78 ms
15,304 KB
testcase_08 AC 77 ms
15,040 KB
testcase_09 AC 76 ms
15,092 KB
testcase_10 AC 76 ms
15,320 KB
testcase_11 AC 77 ms
15,308 KB
testcase_12 AC 77 ms
15,304 KB
testcase_13 AC 76 ms
15,264 KB
testcase_14 AC 81 ms
15,676 KB
testcase_15 AC 78 ms
15,100 KB
testcase_16 AC 90 ms
16,300 KB
testcase_17 AC 115 ms
17,488 KB
testcase_18 AC 92 ms
16,148 KB
testcase_19 AC 260 ms
30,868 KB
testcase_20 AC 365 ms
33,356 KB
testcase_21 AC 77 ms
15,204 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

def f(nums)
  nums.sum
end

def g(nums)
  nums.inject(:*)
end

set = Hash.new

K.upto(N) do |c|
  A.combination(c) do |nums|
    set[f(nums)] = true
    set[g(nums)] = true
  end
end

puts set.size
0