結果

問題 No.1701 half price
ユーザー 小野寺健小野寺健
提出日時 2021-10-30 21:10:56
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 335 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 333,184 KB
最終ジャッジ日時 2024-04-16 16:28:14
合計ジャッジ時間 6,352 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
12,160 KB
testcase_01 AC 89 ms
12,288 KB
testcase_02 AC 91 ms
12,288 KB
testcase_03 AC 89 ms
12,160 KB
testcase_04 AC 95 ms
12,160 KB
testcase_05 AC 88 ms
12,288 KB
testcase_06 AC 92 ms
12,160 KB
testcase_07 AC 109 ms
13,056 KB
testcase_08 WA -
testcase_09 AC 91 ms
12,160 KB
testcase_10 AC 89 ms
12,160 KB
testcase_11 AC 88 ms
12,288 KB
testcase_12 AC 88 ms
12,288 KB
testcase_13 AC 91 ms
12,160 KB
testcase_14 AC 89 ms
12,160 KB
testcase_15 AC 89 ms
12,288 KB
testcase_16 AC 91 ms
12,160 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 88 ms
12,288 KB
testcase_21 AC 2,218 ms
333,184 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, W = gets.split(" ").map{|s| s.to_i}

a = gets.split(" ").map{|s| s.to_i}

w0 = [[0, []]]

0.upto(N-1) {|i|
	w1 = []
	w0.each {|w, v|
		w1 << [w, v]
		tmp = [w + a[i] / 2, v + [i]]
		w1 << tmp if tmp[0] <= W
		tmp = [w + a[i], v + [i]]
		w1 << tmp if tmp[0] <= W
	}
	w0 = w1
}

puts w0.filter{|x, y| x == W}.map{|x, y| y}.uniq.length
0