結果

問題 No.190 Dry Wet Moist
ユーザー simansiman
提出日時 2016-03-28 09:11:41
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 871 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 42,080 KB
最終ジャッジ日時 2024-04-10 04:20:00
合計ジャッジ時間 7,921 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
12,160 KB
testcase_01 AC 96 ms
12,416 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 438 ms
37,620 KB
testcase_23 WA -
testcase_24 AC 437 ms
39,496 KB
testcase_25 AC 95 ms
12,288 KB
testcase_26 AC 94 ms
12,160 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  DRY = 0
  WET = 1
  MOIST = 2

  def initialize
    n = gets.to_i
    a = gets.chomp.split.map(&:to_i)

    dry = Array.new(n, false)
    wet = Array.new(n, false)
    moist = Array.new(n, false)

    answer = Array.new(3, 0)
    
    a.sort_by{|i| 10 ** 5 * i.abs + i}.each_cons(2).with_index(0) do |i, j|
      if i[0] + i[1] < 0 && !dry[j] && !dry[j+1]
        answer[DRY] += 1
        dry[j] = true
        dry[j+1] = true
      end

      if i[0] + i[1] == 0 && !moist[j] && !moist[j+1]
        answer[MOIST] += 1
        moist[j] = true
        moist[j+1] = true
      end
    end

    a.sort_by{|i| 10 ** 5 * i.abs - i}.each_cons(2).with_index(0) do |i, j|
      if i[0] + i[1] > 0 && !wet[j] && !wet[j+1]
        answer[WET] += 1
        wet[j] = true
        wet[j+1] = true
      end
    end

    puts answer.join(' ')
  end
end

Yukicoder.new
0