結果

問題 No.1765 While Shining
ユーザー yudedakoyudedako
提出日時 2022-01-24 23:50:30
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,135 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 9,654 ms
コンパイル使用メモリ 267,196 KB
実行使用メモリ 76,812 KB
最終ジャッジ日時 2023-08-21 15:07:06
合計ジャッジ時間 39,908 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 947 ms
61,892 KB
testcase_01 AC 947 ms
61,796 KB
testcase_02 AC 933 ms
61,840 KB
testcase_03 AC 935 ms
61,784 KB
testcase_04 AC 938 ms
61,912 KB
testcase_05 AC 945 ms
61,564 KB
testcase_06 AC 942 ms
61,852 KB
testcase_07 AC 973 ms
61,968 KB
testcase_08 AC 956 ms
61,896 KB
testcase_09 AC 1,133 ms
67,208 KB
testcase_10 AC 1,125 ms
76,428 KB
testcase_11 AC 1,118 ms
76,480 KB
testcase_12 AC 1,124 ms
76,492 KB
testcase_13 AC 1,116 ms
74,500 KB
testcase_14 AC 1,127 ms
76,540 KB
testcase_15 AC 1,118 ms
76,544 KB
testcase_16 AC 1,118 ms
76,536 KB
testcase_17 AC 1,128 ms
76,420 KB
testcase_18 AC 1,125 ms
76,612 KB
testcase_19 AC 1,135 ms
76,408 KB
testcase_20 AC 1,124 ms
76,612 KB
testcase_21 AC 1,123 ms
76,272 KB
testcase_22 AC 1,118 ms
76,768 KB
testcase_23 AC 1,135 ms
76,812 KB
testcase_24 AC 1,130 ms
76,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.io.StdIn.*



@main def main =
  val n = readLine().toInt
  val cell = readLine().split(' ').map(_.toInt)
  var last = n - 1
  var result = 0L
  for i <- n - 2 to 0 by -1 do
    if cell(i) == cell(i + 1) then
      last = i + 1
    if cell(i) == 1 then
      result += last - i
  println(result)
0