結果

問題 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
コンパイル時間 12,616 ms
コンパイル使用メモリ 265,384 KB
実行使用メモリ 79,120 KB
最終ジャッジ日時 2024-05-08 20:35:03
合計ジャッジ時間 41,412 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 913 ms
63,176 KB
testcase_01 AC 919 ms
63,264 KB
testcase_02 AC 916 ms
63,132 KB
testcase_03 AC 921 ms
63,144 KB
testcase_04 AC 925 ms
63,100 KB
testcase_05 AC 932 ms
63,144 KB
testcase_06 AC 921 ms
63,368 KB
testcase_07 AC 911 ms
63,148 KB
testcase_08 AC 932 ms
63,108 KB
testcase_09 AC 1,082 ms
70,372 KB
testcase_10 AC 1,099 ms
78,244 KB
testcase_11 AC 1,088 ms
76,648 KB
testcase_12 AC 1,099 ms
77,668 KB
testcase_13 AC 1,084 ms
71,936 KB
testcase_14 AC 1,104 ms
78,924 KB
testcase_15 AC 1,103 ms
78,892 KB
testcase_16 AC 1,105 ms
78,856 KB
testcase_17 AC 1,089 ms
78,888 KB
testcase_18 AC 1,104 ms
79,052 KB
testcase_19 AC 1,107 ms
79,068 KB
testcase_20 AC 1,095 ms
79,076 KB
testcase_21 AC 1,096 ms
79,120 KB
testcase_22 AC 1,135 ms
78,952 KB
testcase_23 AC 1,103 ms
78,964 KB
testcase_24 AC 1,101 ms
79,048 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