結果

問題 No.1765 While Shining
ユーザー simansiman
提出日時 2021-11-28 15:32:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 185 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 11,408 KB
実行使用メモリ 27,112 KB
最終ジャッジ日時 2023-09-14 02:05:27
合計ジャッジ時間 5,258 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
15,340 KB
testcase_01 AC 70 ms
15,252 KB
testcase_02 AC 70 ms
15,272 KB
testcase_03 AC 70 ms
15,328 KB
testcase_04 AC 70 ms
15,148 KB
testcase_05 AC 70 ms
15,132 KB
testcase_06 AC 68 ms
15,340 KB
testcase_07 AC 67 ms
15,172 KB
testcase_08 AC 71 ms
15,084 KB
testcase_09 AC 123 ms
22,736 KB
testcase_10 AC 147 ms
25,888 KB
testcase_11 AC 139 ms
24,764 KB
testcase_12 AC 142 ms
25,488 KB
testcase_13 AC 129 ms
24,588 KB
testcase_14 AC 144 ms
27,112 KB
testcase_15 AC 150 ms
26,952 KB
testcase_16 AC 147 ms
27,060 KB
testcase_17 AC 145 ms
26,848 KB
testcase_18 AC 144 ms
26,876 KB
testcase_19 AC 146 ms
27,076 KB
testcase_20 AC 150 ms
26,944 KB
testcase_21 AC 149 ms
27,056 KB
testcase_22 AC 158 ms
26,968 KB
testcase_23 AC 153 ms
26,952 KB
testcase_24 AC 148 ms
27,084 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
A = gets.split.map(&:to_i)

ans = 0
cnt = 1

(N - 2).downto(0) do |i|
  ans += cnt if A[i] == 1

  if A[i] == A[i - 1]
    cnt = 1
  else
    cnt += 1
  end
end

puts ans
0