結果

問題 No.1505 Zero-Product Ranges
ユーザー kept1994
提出日時 2022-04-24 18:16:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 111,232 KB
最終ジャッジ日時 2024-06-26 05:10:10
合計ジャッジ時間 6,924 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys

def main():
    # N, K = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))
    nums = []
    c = 0
    for aa in A:
        if aa == 0:
            nums.append(c)
            c = 0
        else:
            c += 1
    nums.append(c)
    ans = (1 + N) * N // 2
    for i in nums:
        ans -= (1 + i) * i // 2
    print(ans)
    return
    


if __name__ == '__main__':
    main()
0