結果

問題 No.1505 Zero-Product Ranges
ユーザー vwxyzvwxyz
提出日時 2022-01-13 18:37:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,932 KB
最終ジャッジ日時 2024-04-28 16:09:59
合計ジャッジ時間 8,449 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,624 KB
testcase_01 AC 29 ms
10,624 KB
testcase_02 AC 29 ms
10,624 KB
testcase_03 AC 119 ms
13,772 KB
testcase_04 AC 225 ms
27,932 KB
testcase_05 AC 66 ms
11,884 KB
testcase_06 AC 65 ms
11,984 KB
testcase_07 AC 55 ms
11,648 KB
testcase_08 AC 60 ms
11,648 KB
testcase_09 AC 59 ms
11,520 KB
testcase_10 AC 92 ms
16,152 KB
testcase_11 AC 106 ms
17,544 KB
testcase_12 AC 83 ms
15,048 KB
testcase_13 AC 147 ms
20,616 KB
testcase_14 AC 130 ms
19,484 KB
testcase_15 AC 218 ms
26,944 KB
testcase_16 AC 180 ms
20,024 KB
testcase_17 AC 181 ms
19,768 KB
testcase_18 AC 183 ms
20,024 KB
testcase_19 AC 31 ms
10,624 KB
testcase_20 AC 30 ms
10,624 KB
testcase_21 AC 31 ms
10,624 KB
testcase_22 AC 174 ms
19,876 KB
testcase_23 AC 173 ms
19,812 KB
testcase_24 AC 171 ms
19,780 KB
testcase_25 AC 164 ms
19,372 KB
testcase_26 AC 172 ms
19,780 KB
testcase_27 AC 169 ms
19,212 KB
testcase_28 AC 174 ms
19,228 KB
testcase_29 AC 176 ms
19,816 KB
testcase_30 AC 178 ms
20,016 KB
testcase_31 AC 171 ms
19,384 KB
testcase_32 AC 109 ms
15,376 KB
testcase_33 AC 106 ms
14,852 KB
testcase_34 AC 114 ms
15,732 KB
testcase_35 AC 92 ms
14,360 KB
testcase_36 AC 95 ms
14,388 KB
testcase_37 AC 109 ms
15,104 KB
testcase_38 AC 100 ms
14,956 KB
testcase_39 AC 102 ms
14,852 KB
testcase_40 AC 105 ms
15,228 KB
testcase_41 AC 115 ms
15,852 KB
testcase_42 AC 38 ms
11,136 KB
testcase_43 AC 43 ms
11,392 KB
testcase_44 AC 41 ms
11,392 KB
testcase_45 AC 42 ms
11,392 KB
testcase_46 AC 37 ms
11,264 KB
testcase_47 AC 44 ms
11,520 KB
testcase_48 AC 39 ms
11,264 KB
testcase_49 AC 33 ms
10,752 KB
testcase_50 AC 39 ms
11,392 KB
testcase_51 AC 42 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))
ans=N*(N+1)//2
L,R=[0],[]
for i in range(1,N+1):
    if A[i-1]==0:
        L.append(i)
for i in range(N):
    if A[i]==0:
        R.append(i)
R.append(N)
for l,r in zip(L,R):
    d=r-l
    ans-=d*(d+1)//2
print(ans)
0