結果

問題 No.1765 While Shining
ユーザー アナスタシア
提出日時 2021-12-06 21:50:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-07-07 09:33:31
合計ジャッジ時間 2,995 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
As = list(map(int, input().split()))

total, value = 0, 0
target = 1

for a in As[:-1]:
    if a == 1:
        if target == 1:
            value += 1
            target = 0
        else:
            value = 1
    else:
        if target == 0:
            pass
        else:
            value = 0
        target = 1
    total += value

print(total)
0