結果

問題 No.1505 Zero-Product Ranges
ユーザー brthyyjpbrthyyjp
提出日時 2021-05-15 18:42:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 103,872 KB
最終ジャッジ日時 2024-04-14 08:54:20
合計ジャッジ時間 5,859 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,464 KB
testcase_01 AC 39 ms
52,832 KB
testcase_02 AC 39 ms
53,600 KB
testcase_03 AC 79 ms
97,200 KB
testcase_04 AC 77 ms
96,620 KB
testcase_05 AC 58 ms
74,644 KB
testcase_06 AC 59 ms
74,556 KB
testcase_07 AC 55 ms
71,968 KB
testcase_08 AC 54 ms
72,792 KB
testcase_09 AC 53 ms
71,484 KB
testcase_10 AC 56 ms
73,156 KB
testcase_11 AC 57 ms
74,504 KB
testcase_12 AC 52 ms
70,844 KB
testcase_13 AC 65 ms
84,836 KB
testcase_14 AC 62 ms
80,560 KB
testcase_15 AC 77 ms
96,980 KB
testcase_16 AC 88 ms
103,872 KB
testcase_17 AC 88 ms
102,028 KB
testcase_18 AC 86 ms
102,780 KB
testcase_19 AC 39 ms
52,544 KB
testcase_20 AC 38 ms
52,648 KB
testcase_21 AC 38 ms
53,196 KB
testcase_22 AC 86 ms
102,580 KB
testcase_23 AC 86 ms
103,400 KB
testcase_24 AC 85 ms
102,296 KB
testcase_25 AC 82 ms
98,156 KB
testcase_26 AC 86 ms
101,936 KB
testcase_27 AC 82 ms
98,848 KB
testcase_28 AC 83 ms
99,672 KB
testcase_29 AC 86 ms
103,692 KB
testcase_30 AC 87 ms
103,756 KB
testcase_31 AC 87 ms
102,236 KB
testcase_32 AC 67 ms
82,376 KB
testcase_33 AC 65 ms
81,488 KB
testcase_34 AC 72 ms
84,540 KB
testcase_35 AC 61 ms
77,728 KB
testcase_36 AC 62 ms
78,892 KB
testcase_37 AC 65 ms
82,124 KB
testcase_38 AC 66 ms
82,080 KB
testcase_39 AC 65 ms
82,320 KB
testcase_40 AC 64 ms
82,268 KB
testcase_41 AC 67 ms
85,128 KB
testcase_42 AC 48 ms
63,120 KB
testcase_43 AC 50 ms
65,036 KB
testcase_44 AC 48 ms
65,344 KB
testcase_45 AC 49 ms
64,776 KB
testcase_46 AC 47 ms
63,508 KB
testcase_47 AC 49 ms
65,480 KB
testcase_48 AC 47 ms
63,604 KB
testcase_49 AC 47 ms
61,944 KB
testcase_50 AC 47 ms
63,716 KB
testcase_51 AC 49 ms
65,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
ans = n*(n+1)//2
X = []
cur = A[0]
cnt = 0
for a in A:
    if a == cur:
        cnt += 1
    else:
        if cur == 1:
            X.append(cnt)
        cur = a
        cnt = 1
else:
    if cur == 1:
        X.append(cnt)

for x in X:
    ans -= x*(x+1)//2
print(ans)
0