結果

問題 No.1505 Zero-Product Ranges
ユーザー keijakkeijak
提出日時 2021-05-14 23:33:44
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 386 ms
使用メモリ 18,104 KB
最終ジャッジ日時 2022-11-25 23:03:05
合計ジャッジ時間 5,741 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 17 ms
7,576 KB
testcase_01 AC 16 ms
7,772 KB
testcase_02 AC 16 ms
7,588 KB
testcase_03 AC 90 ms
11,016 KB
testcase_04 AC 90 ms
10,864 KB
testcase_05 AC 45 ms
9,180 KB
testcase_06 AC 44 ms
9,044 KB
testcase_07 AC 38 ms
8,664 KB
testcase_08 AC 41 ms
8,912 KB
testcase_09 AC 39 ms
8,708 KB
testcase_10 AC 40 ms
8,772 KB
testcase_11 AC 46 ms
9,124 KB
testcase_12 AC 35 ms
8,664 KB
testcase_13 AC 59 ms
9,880 KB
testcase_14 AC 54 ms
9,704 KB
testcase_15 AC 86 ms
11,104 KB
testcase_16 AC 122 ms
18,104 KB
testcase_17 AC 123 ms
17,880 KB
testcase_18 AC 124 ms
17,864 KB
testcase_19 AC 16 ms
7,592 KB
testcase_20 AC 16 ms
7,580 KB
testcase_21 AC 15 ms
7,780 KB
testcase_22 AC 122 ms
17,572 KB
testcase_23 AC 120 ms
17,656 KB
testcase_24 AC 117 ms
17,300 KB
testcase_25 AC 111 ms
17,068 KB
testcase_26 AC 116 ms
17,344 KB
testcase_27 AC 114 ms
17,076 KB
testcase_28 AC 116 ms
17,212 KB
testcase_29 AC 119 ms
17,712 KB
testcase_30 AC 122 ms
17,948 KB
testcase_31 AC 116 ms
17,272 KB
testcase_32 AC 66 ms
12,908 KB
testcase_33 AC 63 ms
12,412 KB
testcase_34 AC 70 ms
13,264 KB
testcase_35 AC 56 ms
11,788 KB
testcase_36 AC 58 ms
12,088 KB
testcase_37 AC 66 ms
12,852 KB
testcase_38 AC 62 ms
12,300 KB
testcase_39 AC 64 ms
12,748 KB
testcase_40 AC 67 ms
12,840 KB
testcase_41 AC 73 ms
13,488 KB
testcase_42 AC 22 ms
8,456 KB
testcase_43 AC 25 ms
8,776 KB
testcase_44 AC 24 ms
8,548 KB
testcase_45 AC 24 ms
8,692 KB
testcase_46 AC 21 ms
8,424 KB
testcase_47 AC 26 ms
8,852 KB
testcase_48 AC 21 ms
8,460 KB
testcase_49 AC 18 ms
8,172 KB
testcase_50 AC 22 ms
8,604 KB
testcase_51 AC 24 ms
8,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

try:
    import frosch

    frosch.hook()
except ImportError:
    pass


def dump(*a, **kw):
    print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = int(sys.stdin.readline())
    a = [int(x) for x in sys.stdin.readline().split()]
    b = []
    for x in a:
        if b and b[-1][0] == x:
            b[-1][1] += 1
        else:
            b.append([x, 1])
    ones = 0
    for (k, v) in b:
        if k == 1:
            ones += v * (v + 1) // 2
    total = n * (n + 1) // 2
    return total - ones


print(solve())
0