結果

問題 No.1505 Zero-Product Ranges
ユーザー kept1994kept1994
提出日時 2022-04-24 18:16:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 1,344 ms
コンパイル使用メモリ 86,188 KB
実行使用メモリ 117,344 KB
最終ジャッジ日時 2023-09-08 11:55:33
合計ジャッジ時間 9,768 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,952 KB
testcase_01 AC 69 ms
70,996 KB
testcase_02 AC 71 ms
71,012 KB
testcase_03 AC 106 ms
103,864 KB
testcase_04 AC 113 ms
117,344 KB
testcase_05 AC 85 ms
85,412 KB
testcase_06 AC 84 ms
84,876 KB
testcase_07 AC 81 ms
82,072 KB
testcase_08 AC 83 ms
83,312 KB
testcase_09 AC 81 ms
82,176 KB
testcase_10 AC 87 ms
87,488 KB
testcase_11 AC 91 ms
89,764 KB
testcase_12 AC 88 ms
84,872 KB
testcase_13 AC 103 ms
100,352 KB
testcase_14 AC 95 ms
96,356 KB
testcase_15 AC 114 ms
117,068 KB
testcase_16 AC 114 ms
108,616 KB
testcase_17 AC 113 ms
108,568 KB
testcase_18 AC 112 ms
109,932 KB
testcase_19 AC 71 ms
71,000 KB
testcase_20 AC 70 ms
71,012 KB
testcase_21 AC 69 ms
70,708 KB
testcase_22 AC 113 ms
108,476 KB
testcase_23 AC 110 ms
109,844 KB
testcase_24 AC 111 ms
109,104 KB
testcase_25 AC 113 ms
106,428 KB
testcase_26 AC 114 ms
109,532 KB
testcase_27 AC 111 ms
106,336 KB
testcase_28 AC 110 ms
106,412 KB
testcase_29 AC 113 ms
108,524 KB
testcase_30 AC 113 ms
109,848 KB
testcase_31 AC 112 ms
109,552 KB
testcase_32 AC 94 ms
90,916 KB
testcase_33 AC 93 ms
90,784 KB
testcase_34 AC 95 ms
92,960 KB
testcase_35 AC 89 ms
86,796 KB
testcase_36 AC 90 ms
89,156 KB
testcase_37 AC 91 ms
91,004 KB
testcase_38 AC 91 ms
90,528 KB
testcase_39 AC 92 ms
91,168 KB
testcase_40 AC 98 ms
90,776 KB
testcase_41 AC 96 ms
93,560 KB
testcase_42 AC 78 ms
75,672 KB
testcase_43 AC 79 ms
76,200 KB
testcase_44 AC 78 ms
75,748 KB
testcase_45 AC 77 ms
75,888 KB
testcase_46 AC 76 ms
75,792 KB
testcase_47 AC 78 ms
76,348 KB
testcase_48 AC 76 ms
76,092 KB
testcase_49 AC 76 ms
75,756 KB
testcase_50 AC 78 ms
75,664 KB
testcase_51 AC 77 ms
76,244 KB
権限があれば一括ダウンロードができます

ソースコード

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