結果

問題 No.1505 Zero-Product Ranges
ユーザー ThetaTheta
提出日時 2022-12-13 13:27:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 477 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,552 KB
実行使用メモリ 11,440 KB
最終ジャッジ日時 2023-08-07 05:38:02
合計ジャッジ時間 4,951 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,852 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 15 ms
7,840 KB
testcase_03 AC 55 ms
11,336 KB
testcase_04 AC 63 ms
11,292 KB
testcase_05 AC 31 ms
9,312 KB
testcase_06 AC 31 ms
9,360 KB
testcase_07 AC 26 ms
8,984 KB
testcase_08 AC 28 ms
9,116 KB
testcase_09 AC 31 ms
9,020 KB
testcase_10 AC 30 ms
9,104 KB
testcase_11 AC 35 ms
9,536 KB
testcase_12 AC 28 ms
8,952 KB
testcase_13 AC 43 ms
10,352 KB
testcase_14 AC 41 ms
9,960 KB
testcase_15 AC 60 ms
11,252 KB
testcase_16 AC 62 ms
11,336 KB
testcase_17 AC 63 ms
11,416 KB
testcase_18 AC 62 ms
11,332 KB
testcase_19 AC 15 ms
7,844 KB
testcase_20 AC 15 ms
7,876 KB
testcase_21 AC 15 ms
7,804 KB
testcase_22 AC 62 ms
11,304 KB
testcase_23 AC 61 ms
11,292 KB
testcase_24 AC 59 ms
11,356 KB
testcase_25 AC 58 ms
11,228 KB
testcase_26 AC 59 ms
11,356 KB
testcase_27 AC 58 ms
11,256 KB
testcase_28 AC 58 ms
11,400 KB
testcase_29 AC 60 ms
11,440 KB
testcase_30 AC 63 ms
11,216 KB
testcase_31 AC 60 ms
11,300 KB
testcase_32 AC 40 ms
10,012 KB
testcase_33 AC 38 ms
9,652 KB
testcase_34 AC 40 ms
10,104 KB
testcase_35 AC 34 ms
9,516 KB
testcase_36 AC 35 ms
9,404 KB
testcase_37 AC 39 ms
9,948 KB
testcase_38 AC 38 ms
9,636 KB
testcase_39 AC 38 ms
9,728 KB
testcase_40 AC 39 ms
9,900 KB
testcase_41 AC 42 ms
10,204 KB
testcase_42 AC 18 ms
8,344 KB
testcase_43 AC 19 ms
8,208 KB
testcase_44 AC 19 ms
8,352 KB
testcase_45 AC 19 ms
8,392 KB
testcase_46 AC 18 ms
8,256 KB
testcase_47 AC 20 ms
8,476 KB
testcase_48 AC 18 ms
8,344 KB
testcase_49 AC 17 ms
8,192 KB
testcase_50 AC 18 ms
8,236 KB
testcase_51 AC 19 ms
8,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    A = list(map(int, input().split()))

    all_patterns = N * (N+1) // 2
    current_length = 0
    patterns_1 = 0
    for A_elm in A:
        if A_elm == 1:
            current_length += 1
        else:
            patterns_1 += current_length * (current_length + 1) // 2
            current_length = 0
    patterns_1 += current_length * (current_length + 1) // 2
    print(all_patterns - patterns_1)


if __name__ == "__main__":
    main()
0