結果

問題 No.1505 Zero-Product Ranges
ユーザー ripityripity
提出日時 2021-12-18 16:13:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 214 bytes
コンパイル時間 129 ms
コンパイル使用メモリ 10,744 KB
実行使用メモリ 11,496 KB
最終ジャッジ日時 2023-10-13 17:58:28
合計ジャッジ時間 4,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,932 KB
testcase_01 AC 13 ms
7,772 KB
testcase_02 AC 13 ms
7,792 KB
testcase_03 AC 64 ms
11,360 KB
testcase_04 AC 122 ms
11,372 KB
testcase_05 AC 35 ms
9,332 KB
testcase_06 AC 32 ms
9,340 KB
testcase_07 AC 28 ms
8,968 KB
testcase_08 AC 32 ms
8,996 KB
testcase_09 AC 28 ms
9,096 KB
testcase_10 AC 48 ms
9,012 KB
testcase_11 AC 53 ms
9,416 KB
testcase_12 AC 41 ms
9,056 KB
testcase_13 AC 74 ms
10,336 KB
testcase_14 AC 66 ms
10,048 KB
testcase_15 AC 117 ms
11,308 KB
testcase_16 AC 91 ms
11,380 KB
testcase_17 AC 92 ms
11,408 KB
testcase_18 AC 99 ms
11,232 KB
testcase_19 AC 14 ms
7,748 KB
testcase_20 AC 14 ms
7,896 KB
testcase_21 AC 14 ms
7,836 KB
testcase_22 AC 94 ms
11,292 KB
testcase_23 AC 95 ms
11,340 KB
testcase_24 AC 88 ms
11,340 KB
testcase_25 AC 87 ms
11,304 KB
testcase_26 AC 87 ms
11,256 KB
testcase_27 AC 85 ms
11,244 KB
testcase_28 AC 85 ms
11,316 KB
testcase_29 AC 88 ms
11,496 KB
testcase_30 AC 93 ms
11,276 KB
testcase_31 AC 88 ms
11,328 KB
testcase_32 AC 52 ms
9,948 KB
testcase_33 AC 51 ms
9,668 KB
testcase_34 AC 56 ms
10,004 KB
testcase_35 AC 44 ms
9,356 KB
testcase_36 AC 48 ms
9,384 KB
testcase_37 AC 54 ms
9,852 KB
testcase_38 AC 48 ms
9,644 KB
testcase_39 AC 48 ms
9,600 KB
testcase_40 AC 49 ms
9,836 KB
testcase_41 AC 57 ms
10,144 KB
testcase_42 AC 18 ms
8,160 KB
testcase_43 AC 20 ms
8,288 KB
testcase_44 AC 18 ms
8,308 KB
testcase_45 AC 20 ms
8,292 KB
testcase_46 AC 18 ms
8,244 KB
testcase_47 AC 20 ms
8,460 KB
testcase_48 AC 18 ms
8,244 KB
testcase_49 AC 15 ms
8,124 KB
testcase_50 AC 19 ms
8,292 KB
testcase_51 AC 20 ms
8,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
ans = N*(N+1)//2;
frag = 0
for i in range(N):
    if A[i] == 0:
        ans -= (i-frag)*(i-frag+1)//2;
        frag = i+1
ans -= (N-frag)*(N-frag+1)//2
print(ans)
0