結果

問題 No.1505 Zero-Product Ranges
ユーザー Super SolenoidSuper Solenoid
提出日時 2021-05-18 15:38:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 299 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 99,840 KB
最終ジャッジ日時 2024-04-17 05:02:55
合計ジャッジ時間 6,363 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,584 KB
testcase_01 AC 41 ms
51,584 KB
testcase_02 AC 41 ms
51,328 KB
testcase_03 AC 85 ms
96,384 KB
testcase_04 AC 85 ms
96,384 KB
testcase_05 AC 65 ms
74,624 KB
testcase_06 AC 66 ms
74,112 KB
testcase_07 AC 61 ms
71,040 KB
testcase_08 AC 62 ms
72,576 KB
testcase_09 AC 60 ms
71,168 KB
testcase_10 AC 63 ms
72,448 KB
testcase_11 AC 66 ms
74,752 KB
testcase_12 AC 60 ms
69,632 KB
testcase_13 AC 74 ms
83,328 KB
testcase_14 AC 71 ms
80,512 KB
testcase_15 AC 86 ms
96,512 KB
testcase_16 AC 94 ms
99,840 KB
testcase_17 AC 96 ms
99,584 KB
testcase_18 AC 106 ms
99,328 KB
testcase_19 AC 42 ms
51,712 KB
testcase_20 AC 42 ms
51,456 KB
testcase_21 AC 43 ms
51,840 KB
testcase_22 AC 94 ms
99,200 KB
testcase_23 AC 95 ms
99,456 KB
testcase_24 AC 96 ms
99,200 KB
testcase_25 AC 92 ms
95,616 KB
testcase_26 AC 94 ms
98,944 KB
testcase_27 AC 92 ms
96,000 KB
testcase_28 AC 90 ms
95,616 KB
testcase_29 AC 95 ms
99,840 KB
testcase_30 AC 95 ms
99,328 KB
testcase_31 AC 94 ms
98,816 KB
testcase_32 AC 75 ms
80,384 KB
testcase_33 AC 71 ms
79,744 KB
testcase_34 AC 74 ms
82,304 KB
testcase_35 AC 68 ms
75,776 KB
testcase_36 AC 70 ms
77,568 KB
testcase_37 AC 74 ms
80,128 KB
testcase_38 AC 73 ms
79,360 KB
testcase_39 AC 73 ms
79,872 KB
testcase_40 AC 73 ms
80,000 KB
testcase_41 AC 76 ms
82,048 KB
testcase_42 AC 56 ms
63,360 KB
testcase_43 AC 56 ms
64,000 KB
testcase_44 AC 55 ms
63,360 KB
testcase_45 AC 57 ms
64,640 KB
testcase_46 AC 55 ms
62,976 KB
testcase_47 AC 57 ms
64,768 KB
testcase_48 AC 54 ms
63,232 KB
testcase_49 AC 54 ms
62,080 KB
testcase_50 AC 56 ms
64,128 KB
testcase_51 AC 57 ms
64,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
a.append(0)

s = a[0]
k = 0
nc = 0

for i in range(n + 1):
    if s == 0 and a[i] == 0:
        nc += (i - k)*(i - k + 1)/2
        s = 1
        continue
    if s == 1 and a[i] == 1:
        k = i
        s = 0

print(int(n * (n + 1) / 2 - nc)) 
0