結果

問題 No.2343 (l+r)/2
ユーザー maguroflymagurofly
提出日時 2023-06-09 22:13:37
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 288 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 27,876 KB
最終ジャッジ日時 2023-08-30 13:25:57
合計ジャッジ時間 4,122 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,032 KB
testcase_01 AC 516 ms
27,876 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 112 ms
20,136 KB
testcase_05 AC 96 ms
16,756 KB
testcase_06 AC 94 ms
16,608 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 127 ms
21,544 KB
testcase_12 WA -
testcase_13 AC 103 ms
18,340 KB
testcase_14 AC 136 ms
23,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:4: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

T = gets.to_i
ans = []
T.times do
	n = gets.to_i
	a = gets.split.map { |e| e.to_i }
	ones = 0
	zeros = 0
	prev = 1
	a.each do |x|
		if x == 0
			zeros += 1 if prev != 0
		else
			ones += 1 
		end
		prev = x
	end
	ans << (zeros <= ones && zeros != 0 ? "Yes" : "No")
end
puts ans.join("\n")
0