結果

問題 No.1765 While Shining
コンテスト
ユーザー yudedako
提出日時 2022-01-24 23:50:30
言語 Scala(Beta)
(3.8.2)
コンパイル:
scalac _filename_
実行:
/usr/bin/scala_run _class_
結果
AC  
実行時間 593 ms / 2,000 ms
コード長 309 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,595 ms
コンパイル使用メモリ 273,820 KB
実行使用メモリ 70,980 KB
最終ジャッジ日時 2026-03-09 19:26:03
合計ジャッジ時間 25,129 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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