結果

問題 No.1505 Zero-Product Ranges
ユーザー 👑 H20H20
提出日時 2021-05-15 00:25:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 197 ms
コンパイル使用メモリ 82,148 KB
実行使用メモリ 126,532 KB
最終ジャッジ日時 2024-04-10 05:41:39
合計ジャッジ時間 5,738 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,288 KB
testcase_01 AC 38 ms
53,376 KB
testcase_02 AC 38 ms
52,436 KB
testcase_03 AC 102 ms
126,284 KB
testcase_04 AC 101 ms
126,532 KB
testcase_05 AC 66 ms
86,556 KB
testcase_06 AC 64 ms
86,504 KB
testcase_07 AC 59 ms
79,584 KB
testcase_08 AC 62 ms
82,656 KB
testcase_09 AC 60 ms
80,404 KB
testcase_10 AC 60 ms
82,048 KB
testcase_11 AC 63 ms
86,760 KB
testcase_12 AC 55 ms
77,328 KB
testcase_13 AC 81 ms
100,548 KB
testcase_14 AC 72 ms
95,172 KB
testcase_15 AC 96 ms
125,968 KB
testcase_16 AC 112 ms
117,504 KB
testcase_17 AC 109 ms
117,880 KB
testcase_18 AC 111 ms
117,596 KB
testcase_19 AC 38 ms
53,968 KB
testcase_20 AC 37 ms
53,024 KB
testcase_21 AC 38 ms
53,760 KB
testcase_22 AC 110 ms
117,948 KB
testcase_23 AC 112 ms
117,748 KB
testcase_24 AC 110 ms
117,624 KB
testcase_25 AC 104 ms
112,960 KB
testcase_26 AC 111 ms
117,604 KB
testcase_27 AC 106 ms
112,452 KB
testcase_28 AC 107 ms
112,928 KB
testcase_29 AC 115 ms
117,708 KB
testcase_30 AC 113 ms
117,444 KB
testcase_31 AC 113 ms
117,348 KB
testcase_32 AC 84 ms
94,684 KB
testcase_33 AC 80 ms
95,044 KB
testcase_34 AC 83 ms
97,880 KB
testcase_35 AC 75 ms
90,316 KB
testcase_36 AC 76 ms
92,312 KB
testcase_37 AC 82 ms
94,924 KB
testcase_38 AC 80 ms
94,492 KB
testcase_39 AC 83 ms
94,592 KB
testcase_40 AC 79 ms
94,648 KB
testcase_41 AC 85 ms
97,588 KB
testcase_42 AC 51 ms
67,244 KB
testcase_43 AC 54 ms
71,448 KB
testcase_44 AC 55 ms
71,500 KB
testcase_45 AC 53 ms
70,588 KB
testcase_46 AC 49 ms
67,740 KB
testcase_47 AC 51 ms
72,076 KB
testcase_48 AC 50 ms
68,216 KB
testcase_49 AC 49 ms
64,940 KB
testcase_50 AC 51 ms
68,400 KB
testcase_51 AC 52 ms
69,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
N = int(input())
A = list(map(int, input().split()))
TF = []
for i in range(N):
    TF.append(A[i]!=0)
gr = itertools.groupby(TF)
ans = N+N*(N-1)//2
for key, group in gr:
    le = len(list(group))
    ans -= key*(le+le*(le-1)//2)
print(ans)
0