結果
問題 |
No.1701 half price
|
ユーザー |
|
提出日時 | 2021-10-19 21:46:31 |
言語 | Ruby (3.4.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 448 bytes |
コンパイル時間 | 385 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 19,616 KB |
最終ジャッジ日時 | 2024-09-20 06:25:49 |
合計ジャッジ時間 | 7,981 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 TLE * 1 -- * 15 |
コンパイルメッセージ
Syntax OK
ソースコード
require 'set' N, W = gets.split.map(&:to_i) a = gets.split.map(&:to_i) answer = Set.new (3**N).times do |n| bit_str = n.to_s(3).rjust(N, '0') key = 0 sum = bit_str.chars.each_with_index.inject(0) { |acc, (bit, i)| price = case bit when '0' 0 when '1' key += (1 << i) a[i] else key += (1 << i) a[i] / 2 end acc + price } next unless sum == W answer << key end puts answer.size