結果
問題 | No.190 Dry Wet Moist |
ユーザー |
![]() |
提出日時 | 2016-03-29 05:10:17 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 404 ms / 2,000 ms |
コード長 | 1,252 bytes |
コンパイル時間 | 54 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 41,088 KB |
最終ジャッジ日時 | 2024-10-02 07:15:22 |
合計ジャッジ時間 | 6,784 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
コンパイルメッセージ
Main.rb:10: warning: assigned but unused variable - dry Main.rb:11: warning: assigned but unused variable - wet Main.rb:12: warning: assigned but unused variable - moist Syntax OK
ソースコード
class YukicoderDRY = 0WET = 1MOIST = 2def initializen = gets.to_ia = gets.chomp.split.map(&:to_i).sortdry = Array.new(n, false)wet = Array.new(n, false)moist = Array.new(n, false)answer = Array.new(3, 0)minus = a.select{|i| i < 0}.reverseplus = a.select{|i| i >= 0}mcnt = 0while minus.any? && plus.any?val = minus.shiftif plus[0] + val < 0answer[DRY] += 1plus.shiftelsemcnt += 1endendanswer[DRY] += (mcnt+minus.size)/2minus = a.select{|i| i < 0}.reverseplus = a.select{|i| i >= 0}trush = []while minus.any? && plus.any?val = plus.shiftif minus[0] + val > 0answer[WET] += 1minus.shiftelsetrush << valendendtrush += plusif trush.count(0) > trush.size/2answer[WET] += trush.count{|i| i > 0}elseanswer[WET] += (trush.size/2)endcheckList = Hash.new(0)a.each do |num|if num >= 0 && checkList[-num] > 0answer[MOIST] += 1checkList[-num] -= 1elsif num <= 0checkList[num] += 1endendputs answer.join(' ')endendYukicoder.new