結果

問題 No.1505 Zero-Product Ranges
ユーザー ygd.ygd.
提出日時 2021-05-29 22:57:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 1,578 ms
コンパイル使用メモリ 86,544 KB
実行使用メモリ 119,228 KB
最終ジャッジ日時 2023-08-08 03:45:28
合計ジャッジ時間 10,686 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
90,300 KB
testcase_01 AC 103 ms
90,260 KB
testcase_02 AC 104 ms
90,268 KB
testcase_03 AC 138 ms
119,100 KB
testcase_04 AC 138 ms
119,176 KB
testcase_05 AC 120 ms
100,332 KB
testcase_06 AC 119 ms
99,904 KB
testcase_07 AC 116 ms
97,724 KB
testcase_08 AC 115 ms
98,600 KB
testcase_09 AC 114 ms
97,560 KB
testcase_10 AC 115 ms
98,768 KB
testcase_11 AC 120 ms
100,212 KB
testcase_12 AC 114 ms
96,800 KB
testcase_13 AC 133 ms
107,196 KB
testcase_14 AC 128 ms
105,080 KB
testcase_15 AC 139 ms
119,228 KB
testcase_16 AC 140 ms
118,844 KB
testcase_17 AC 140 ms
118,956 KB
testcase_18 AC 139 ms
118,712 KB
testcase_19 AC 105 ms
90,304 KB
testcase_20 AC 107 ms
90,352 KB
testcase_21 AC 103 ms
90,652 KB
testcase_22 AC 139 ms
118,964 KB
testcase_23 AC 138 ms
118,772 KB
testcase_24 AC 140 ms
118,856 KB
testcase_25 AC 140 ms
115,624 KB
testcase_26 AC 137 ms
118,804 KB
testcase_27 AC 136 ms
115,624 KB
testcase_28 AC 135 ms
115,840 KB
testcase_29 AC 138 ms
119,024 KB
testcase_30 AC 141 ms
119,048 KB
testcase_31 AC 138 ms
119,068 KB
testcase_32 AC 128 ms
103,448 KB
testcase_33 AC 125 ms
103,368 KB
testcase_34 AC 134 ms
104,916 KB
testcase_35 AC 121 ms
100,476 KB
testcase_36 AC 119 ms
101,764 KB
testcase_37 AC 124 ms
103,576 KB
testcase_38 AC 123 ms
102,884 KB
testcase_39 AC 124 ms
103,248 KB
testcase_40 AC 125 ms
103,400 KB
testcase_41 AC 130 ms
105,064 KB
testcase_42 AC 114 ms
91,208 KB
testcase_43 AC 114 ms
91,648 KB
testcase_44 AC 112 ms
91,220 KB
testcase_45 AC 114 ms
91,280 KB
testcase_46 AC 111 ms
91,076 KB
testcase_47 AC 108 ms
91,640 KB
testcase_48 AC 109 ms
91,284 KB
testcase_49 AC 108 ms
90,952 KB
testcase_50 AC 122 ms
91,020 KB
testcase_51 AC 123 ms
91,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys 
from collections import Counter
def main():
    N = int(input())
    A = list(map(int,input().split()))
    MAX = 2*pow(10,5) + 1000
    S = [0]
    for i in range(1,MAX):
        temp = S[-1] + i
        S.append(temp)
    ans = S[N]
    cnt = 0
    for i in range(N):
        if A[i] == 0:
            ans -= S[cnt]
            cnt = 0
        else:
            cnt += 1
    ans -= S[cnt]
    print(ans)

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