結果

問題 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  
実行時間 188 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 10,680 KB
実行使用メモリ 25,696 KB
最終ジャッジ日時 2023-08-10 23:07:29
合計ジャッジ時間 8,036 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,808 KB
testcase_01 AC 15 ms
7,956 KB
testcase_02 AC 15 ms
7,808 KB
testcase_03 AC 90 ms
11,516 KB
testcase_04 AC 188 ms
25,696 KB
testcase_05 AC 45 ms
9,264 KB
testcase_06 AC 42 ms
9,476 KB
testcase_07 AC 35 ms
9,180 KB
testcase_08 AC 38 ms
9,140 KB
testcase_09 AC 36 ms
9,036 KB
testcase_10 AC 63 ms
13,716 KB
testcase_11 AC 78 ms
14,772 KB
testcase_12 AC 58 ms
12,572 KB
testcase_13 AC 111 ms
18,164 KB
testcase_14 AC 99 ms
16,932 KB
testcase_15 AC 169 ms
24,416 KB
testcase_16 AC 135 ms
17,720 KB
testcase_17 AC 140 ms
17,776 KB
testcase_18 AC 142 ms
17,816 KB
testcase_19 AC 15 ms
7,848 KB
testcase_20 AC 15 ms
7,756 KB
testcase_21 AC 15 ms
7,808 KB
testcase_22 AC 138 ms
17,264 KB
testcase_23 AC 128 ms
17,088 KB
testcase_24 AC 126 ms
17,136 KB
testcase_25 AC 122 ms
16,796 KB
testcase_26 AC 123 ms
17,108 KB
testcase_27 AC 123 ms
17,088 KB
testcase_28 AC 128 ms
16,760 KB
testcase_29 AC 135 ms
17,068 KB
testcase_30 AC 136 ms
17,536 KB
testcase_31 AC 133 ms
16,776 KB
testcase_32 AC 77 ms
13,064 KB
testcase_33 AC 75 ms
12,508 KB
testcase_34 AC 80 ms
13,048 KB
testcase_35 AC 65 ms
11,864 KB
testcase_36 AC 69 ms
12,116 KB
testcase_37 AC 74 ms
12,760 KB
testcase_38 AC 73 ms
12,420 KB
testcase_39 AC 73 ms
12,452 KB
testcase_40 AC 79 ms
12,780 KB
testcase_41 AC 87 ms
13,484 KB
testcase_42 AC 22 ms
8,640 KB
testcase_43 AC 25 ms
8,864 KB
testcase_44 AC 23 ms
8,848 KB
testcase_45 AC 23 ms
8,800 KB
testcase_46 AC 19 ms
8,644 KB
testcase_47 AC 25 ms
9,068 KB
testcase_48 AC 22 ms
8,680 KB
testcase_49 AC 18 ms
8,380 KB
testcase_50 AC 21 ms
8,860 KB
testcase_51 AC 24 ms
8,772 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