結果

問題 No.2343 (l+r)/2
ユーザー simansiman
提出日時 2023-06-10 05:52:27
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 357 bytes
コンパイル時間 695 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 23,304 KB
最終ジャッジ日時 2023-08-30 18:07:25
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,044 KB
testcase_01 AC 543 ms
15,240 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 126 ms
20,120 KB
testcase_05 AC 97 ms
16,908 KB
testcase_06 AC 96 ms
16,672 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 102 ms
16,776 KB
testcase_11 AC 173 ms
21,464 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 176 ms
23,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:4: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

T = gets.to_i

T.times do
  n = gets.to_i
  a = gets.split.map(&:to_i)
  memo = a.tally
  memo.default = 0

  a.each_cons(2) do |x, y|
    next if x != y

    if memo[0] > memo[1] && x == 0
      memo[0] -= 1
    end

    if memo[0] < memo[1] && x == 1
      memo[1] -= 1
    end
  end

  if memo[0] == memo[1]
    puts 'Yes'
  else
    puts 'No'
  end
end
0