結果

問題 No.1505 Zero-Product Ranges
ユーザー aminoamino
提出日時 2021-05-14 22:33:40
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 716 ms
使用メモリ 11,772 KB
最終ジャッジ日時 2022-11-25 19:38:27
合計ジャッジ時間 5,667 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 15 ms
7,836 KB
testcase_01 AC 15 ms
7,700 KB
testcase_02 AC 15 ms
7,712 KB
testcase_03 AC 76 ms
11,636 KB
testcase_04 AC 119 ms
11,772 KB
testcase_05 AC 38 ms
9,168 KB
testcase_06 AC 38 ms
9,256 KB
testcase_07 AC 32 ms
8,872 KB
testcase_08 AC 35 ms
9,108 KB
testcase_09 AC 32 ms
8,816 KB
testcase_10 AC 46 ms
8,960 KB
testcase_11 AC 60 ms
9,208 KB
testcase_12 AC 44 ms
8,832 KB
testcase_13 AC 78 ms
10,056 KB
testcase_14 AC 68 ms
9,852 KB
testcase_15 AC 113 ms
11,188 KB
testcase_16 AC 100 ms
11,740 KB
testcase_17 AC 98 ms
11,712 KB
testcase_18 AC 105 ms
11,736 KB
testcase_19 AC 14 ms
7,672 KB
testcase_20 AC 13 ms
7,632 KB
testcase_21 AC 14 ms
7,760 KB
testcase_22 AC 99 ms
11,116 KB
testcase_23 AC 97 ms
11,136 KB
testcase_24 AC 96 ms
11,220 KB
testcase_25 AC 94 ms
10,952 KB
testcase_26 AC 99 ms
11,044 KB
testcase_27 AC 97 ms
10,976 KB
testcase_28 AC 97 ms
11,144 KB
testcase_29 AC 101 ms
11,052 KB
testcase_30 AC 104 ms
11,172 KB
testcase_31 AC 95 ms
11,232 KB
testcase_32 AC 58 ms
9,676 KB
testcase_33 AC 53 ms
9,320 KB
testcase_34 AC 62 ms
9,828 KB
testcase_35 AC 50 ms
9,232 KB
testcase_36 AC 51 ms
9,208 KB
testcase_37 AC 60 ms
9,628 KB
testcase_38 AC 55 ms
9,296 KB
testcase_39 AC 58 ms
9,456 KB
testcase_40 AC 56 ms
9,624 KB
testcase_41 AC 66 ms
9,988 KB
testcase_42 AC 19 ms
8,116 KB
testcase_43 AC 22 ms
8,192 KB
testcase_44 AC 20 ms
8,040 KB
testcase_45 AC 21 ms
8,100 KB
testcase_46 AC 18 ms
8,144 KB
testcase_47 AC 22 ms
8,052 KB
testcase_48 AC 19 ms
7,992 KB
testcase_49 AC 15 ms
7,960 KB
testcase_50 AC 18 ms
8,124 KB
testcase_51 AC 19 ms
8,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def f(n):
    if n < 2:
        return n
    else:
        return n * (n + 1) // 2

n = int(input())
a = list(map(int,input().split()))
c = []
cnt = 0
for i in range(n):
    if a[i] == 0:
        c.append(cnt)
        cnt = 0
    else:
        cnt += 1
c.append(cnt)

ans = f(n)
for i in c:
    ans -= f(i)
print(ans)
0