結果

問題 No.1765 While Shining
ユーザー 小野寺健小野寺健
提出日時 2021-11-28 17:03:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 200 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 27,040 KB
最終ジャッジ日時 2023-09-14 04:11:43
合計ジャッジ時間 4,903 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,132 KB
testcase_01 AC 81 ms
15,116 KB
testcase_02 AC 83 ms
15,244 KB
testcase_03 AC 79 ms
15,300 KB
testcase_04 AC 80 ms
15,268 KB
testcase_05 AC 80 ms
15,212 KB
testcase_06 AC 79 ms
15,136 KB
testcase_07 AC 81 ms
15,008 KB
testcase_08 AC 82 ms
15,064 KB
testcase_09 AC 138 ms
22,912 KB
testcase_10 AC 162 ms
25,896 KB
testcase_11 AC 154 ms
24,896 KB
testcase_12 AC 162 ms
25,532 KB
testcase_13 AC 151 ms
24,548 KB
testcase_14 AC 171 ms
26,856 KB
testcase_15 AC 169 ms
26,968 KB
testcase_16 AC 169 ms
26,932 KB
testcase_17 AC 167 ms
26,928 KB
testcase_18 AC 166 ms
26,864 KB
testcase_19 AC 170 ms
26,864 KB
testcase_20 AC 167 ms
26,928 KB
testcase_21 AC 169 ms
26,924 KB
testcase_22 AC 168 ms
27,020 KB
testcase_23 AC 168 ms
26,996 KB
testcase_24 AC 167 ms
27,040 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split(" ").map{|s| s.to_i}

m0 = 0
m1 = 0
cnt = 0
A[0, N-1].each{|a|
	if a == 1 then
		cnt += 1 + m1
		m0 = 1 + m1
		m1 = 0
	else
		cnt += m0
		m1 = m0
		m0 = 0
	end
}

puts cnt
0