結果
問題 |
No.1430 Coup de Coupon
|
ユーザー |
![]() |
提出日時 | 2021-03-14 16:47:43 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 906 bytes |
コンパイル時間 | 53 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,672 KB |
最終ジャッジ日時 | 2024-11-06 06:33:18 |
合計ジャッジ時間 | 3,958 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 WA * 20 |
コンパイルメッセージ
Syntax OK
ソースコード
def main(argv) (n, c) = gets.chomp.split(' ').map(&:to_i) ps = [0] * n n.times{|i| ps[i] = gets.chomp.to_i} ps.sort!{|a, b| b <=> a} cs1 = [] cs2 = [] c.times do |j| cc = gets.chomp.split(' ').map(&:to_i) if cc[0] == 1 then cs1.push(cc[1]) else # cc[0] == 2 cs2.push(cc[1]) end end cs1.sort{|a, b| b <=> a} cs2.sort{|a, b| b <=> a} total = 0 ps.each do |price| discount = 0 if cs1.size > 0 && cs2.size > 0 then if cs1[0] > cs2[0] * (price / 100) then discount = cs1[0] cs1.shift else discount = cs2[0] * (price / 100) cs2.shift end elsif cs1.size > 0 then discount = cs1[0] cs1.shift elsif cs2.size > 0 then discount = cs2[0] * (price / 100) cs2.shift end total += [price - discount, 0].max end puts total.to_s end main(ARGV) if self.to_s == 'main'