結果

問題 No.2343 (l+r)/2
ユーザー simansiman
提出日時 2023-06-10 07:06:56
言語 Ruby
(3.3.0)
結果
AC  
実行時間 667 ms / 2,000 ms
コード長 294 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 11,416 KB
実行使用メモリ 27,140 KB
最終ジャッジ日時 2023-08-30 18:38:53
合計ジャッジ時間 3,867 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,288 KB
testcase_01 AC 667 ms
15,072 KB
testcase_02 AC 84 ms
15,388 KB
testcase_03 AC 181 ms
15,220 KB
testcase_04 AC 102 ms
19,860 KB
testcase_05 AC 88 ms
16,736 KB
testcase_06 AC 90 ms
16,596 KB
testcase_07 AC 123 ms
16,440 KB
testcase_08 AC 143 ms
16,904 KB
testcase_09 AC 121 ms
16,452 KB
testcase_10 AC 98 ms
17,748 KB
testcase_11 AC 139 ms
23,808 KB
testcase_12 AC 122 ms
20,200 KB
testcase_13 AC 112 ms
20,204 KB
testcase_14 AC 154 ms
27,140 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)

  if a[0] == 1
    a = a.map { |x| x ^ 1 }
  end

  if a[-1] == 1
    puts 'Yes'
  elsif a.each_cons(2).any? { |x, y| x == 1 && y == 1 }
    puts 'Yes'
  elsif a.count(1) >= 4
    puts 'Yes'
  else
    puts 'No'
  end
end
0