結果

問題 No.1505 Zero-Product Ranges
ユーザー keijakkeijak
提出日時 2021-05-14 23:33:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,284 KB
最終ジャッジ日時 2024-04-10 04:09:09
合計ジャッジ時間 5,423 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
10,624 KB
testcase_03 AC 101 ms
14,784 KB
testcase_04 AC 102 ms
14,660 KB
testcase_05 AC 57 ms
12,416 KB
testcase_06 AC 55 ms
12,116 KB
testcase_07 AC 49 ms
11,904 KB
testcase_08 AC 52 ms
11,776 KB
testcase_09 AC 50 ms
11,776 KB
testcase_10 AC 52 ms
11,904 KB
testcase_11 AC 57 ms
12,012 KB
testcase_12 AC 47 ms
11,720 KB
testcase_13 AC 69 ms
12,732 KB
testcase_14 AC 64 ms
12,628 KB
testcase_15 AC 97 ms
14,068 KB
testcase_16 AC 133 ms
21,284 KB
testcase_17 AC 131 ms
21,156 KB
testcase_18 AC 131 ms
21,284 KB
testcase_19 AC 29 ms
10,752 KB
testcase_20 AC 30 ms
10,752 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 130 ms
20,776 KB
testcase_23 AC 129 ms
20,592 KB
testcase_24 AC 124 ms
20,680 KB
testcase_25 AC 120 ms
20,264 KB
testcase_26 AC 121 ms
20,684 KB
testcase_27 AC 119 ms
20,300 KB
testcase_28 AC 123 ms
20,136 KB
testcase_29 AC 128 ms
20,872 KB
testcase_30 AC 130 ms
20,788 KB
testcase_31 AC 125 ms
20,288 KB
testcase_32 AC 80 ms
16,040 KB
testcase_33 AC 76 ms
15,464 KB
testcase_34 AC 84 ms
16,080 KB
testcase_35 AC 69 ms
14,912 KB
testcase_36 AC 71 ms
15,036 KB
testcase_37 AC 77 ms
15,756 KB
testcase_38 AC 74 ms
15,480 KB
testcase_39 AC 76 ms
15,628 KB
testcase_40 AC 77 ms
15,756 KB
testcase_41 AC 86 ms
16,584 KB
testcase_42 AC 36 ms
11,392 KB
testcase_43 AC 39 ms
11,648 KB
testcase_44 AC 37 ms
11,520 KB
testcase_45 AC 38 ms
11,648 KB
testcase_46 AC 34 ms
11,264 KB
testcase_47 AC 40 ms
11,776 KB
testcase_48 AC 36 ms
11,392 KB
testcase_49 AC 33 ms
10,880 KB
testcase_50 AC 36 ms
11,392 KB
testcase_51 AC 37 ms
11,648 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