結果

問題 No.1765 While Shining
ユーザー tomeruntomerun
提出日時 2021-11-26 22:36:07
言語 Crystal
(1.11.2)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 190 bytes
コンパイル時間 19,008 ms
コンパイル使用メモリ 253,192 KB
実行使用メモリ 15,060 KB
最終ジャッジ日時 2023-09-12 05:14:30
合計ジャッジ時間 19,667 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,412 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,408 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 2 ms
4,440 KB
testcase_05 AC 3 ms
4,432 KB
testcase_06 AC 3 ms
4,404 KB
testcase_07 AC 3 ms
4,456 KB
testcase_08 AC 3 ms
4,484 KB
testcase_09 AC 15 ms
10,320 KB
testcase_10 AC 19 ms
11,144 KB
testcase_11 AC 17 ms
11,172 KB
testcase_12 AC 17 ms
11,156 KB
testcase_13 AC 16 ms
11,112 KB
testcase_14 AC 23 ms
14,948 KB
testcase_15 AC 22 ms
14,856 KB
testcase_16 AC 22 ms
14,724 KB
testcase_17 AC 22 ms
15,060 KB
testcase_18 AC 22 ms
14,724 KB
testcase_19 AC 21 ms
14,868 KB
testcase_20 AC 22 ms
14,796 KB
testcase_21 AC 23 ms
14,776 KB
testcase_22 AC 23 ms
14,764 KB
testcase_23 AC 24 ms
14,808 KB
testcase_24 AC 20 ms
14,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
a = read_line.split.map(&.to_i).reverse
s = 1
ans = 0i64
1.upto(n - 1) do |i|
  if a[i] == a[i - 1]
    s = i
  end
  if a[i] == 1
    ans += i - s + 1
  end
end
puts ans
0