結果

問題 No.1463 Hungry Kanten
ユーザー yuruhiyayuruhiya
提出日時 2021-04-02 21:39:43
言語 Crystal
(1.11.2)
結果
AC  
実行時間 915 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 23,406 ms
コンパイル使用メモリ 262,172 KB
実行使用メモリ 134,492 KB
最終ジャッジ日時 2023-08-25 14:53:16
合計ジャッジ時間 27,689 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,724 KB
testcase_01 AC 3 ms
4,896 KB
testcase_02 AC 35 ms
13,168 KB
testcase_03 AC 790 ms
101,828 KB
testcase_04 AC 3 ms
5,144 KB
testcase_05 AC 915 ms
134,492 KB
testcase_06 AC 3 ms
4,884 KB
testcase_07 AC 3 ms
4,744 KB
testcase_08 AC 3 ms
4,900 KB
testcase_09 AC 3 ms
4,936 KB
testcase_10 AC 3 ms
5,116 KB
testcase_11 AC 4 ms
5,356 KB
testcase_12 AC 5 ms
5,616 KB
testcase_13 AC 4 ms
5,272 KB
testcase_14 AC 12 ms
7,564 KB
testcase_15 AC 5 ms
5,868 KB
testcase_16 AC 34 ms
11,440 KB
testcase_17 AC 95 ms
23,012 KB
testcase_18 AC 38 ms
15,244 KB
testcase_19 AC 453 ms
78,568 KB
testcase_20 AC 615 ms
119,892 KB
testcase_21 AC 4 ms
5,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

lib C
  fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end

class String
  def to_i64
    C.strtoll(self, nil, 10)
  end
end

require "big"

n, k = read_line.split.map(&.to_i)
a = read_line.split.map(&.to_big_i)
puts [0, 1].repeated_permutations(n).select { |perm|
  perm.sum >= k
}.flat_map { |perm|
  b = (0...n).select { |i| perm[i] > 0 }.map { |i| a[i] }
  [b.sum, b.reduce(1.to_big_i) { |acc, val| acc * val }]
}.uniq.size
0