結果

問題 No.1505 Zero-Product Ranges
ユーザー TomoyarnTomoyarn
提出日時 2022-01-02 18:12:23
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 607 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 75,264 KB
最終ジャッジ日時 2024-04-20 03:09:05
合計ジャッジ時間 13,101 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,096 KB
testcase_01 AC 42 ms
51,712 KB
testcase_02 AC 31 ms
52,096 KB
testcase_03 AC 62 ms
64,384 KB
testcase_04 AC 46 ms
60,928 KB
testcase_05 AC 1,896 ms
75,264 KB
testcase_06 TLE -
testcase_07 AC 1,146 ms
68,352 KB
testcase_08 AC 1,625 ms
71,648 KB
testcase_09 AC 1,423 ms
70,528 KB
testcase_10 AC 41 ms
55,168 KB
testcase_11 AC 42 ms
56,064 KB
testcase_12 AC 40 ms
54,912 KB
testcase_13 AC 42 ms
57,984 KB
testcase_14 AC 41 ms
57,216 KB
testcase_15 AC 45 ms
61,056 KB
testcase_16 AC 105 ms
66,688 KB
testcase_17 AC 121 ms
68,352 KB
testcase_18 AC 100 ms
68,224 KB
testcase_19 AC 42 ms
52,352 KB
testcase_20 AC 39 ms
51,840 KB
testcase_21 AC 34 ms
51,712 KB
testcase_22 AC 111 ms
67,584 KB
testcase_23 AC 111 ms
67,584 KB
testcase_24 AC 104 ms
67,072 KB
testcase_25 AC 100 ms
65,792 KB
testcase_26 AC 117 ms
67,328 KB
testcase_27 AC 91 ms
66,048 KB
testcase_28 AC 109 ms
66,816 KB
testcase_29 AC 103 ms
66,432 KB
testcase_30 AC 102 ms
66,432 KB
testcase_31 AC 106 ms
67,072 KB
testcase_32 AC 70 ms
59,904 KB
testcase_33 AC 70 ms
59,776 KB
testcase_34 AC 79 ms
59,776 KB
testcase_35 AC 74 ms
58,496 KB
testcase_36 AC 69 ms
58,112 KB
testcase_37 AC 73 ms
59,776 KB
testcase_38 AC 64 ms
58,880 KB
testcase_39 AC 71 ms
59,776 KB
testcase_40 AC 70 ms
59,520 KB
testcase_41 AC 79 ms
60,416 KB
testcase_42 AC 42 ms
53,220 KB
testcase_43 AC 45 ms
53,120 KB
testcase_44 AC 45 ms
52,736 KB
testcase_45 AC 48 ms
52,864 KB
testcase_46 AC 46 ms
52,736 KB
testcase_47 AC 37 ms
53,376 KB
testcase_48 AC 42 ms
52,480 KB
testcase_49 AC 44 ms
52,736 KB
testcase_50 AC 39 ms
52,608 KB
testcase_51 AC 40 ms
53,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = input().replace(' ', '')

all = N * (N + 1) // 2

def search_one():
    a = 0
    b = len(A)
    while True:
        j = a + (b - a) // 2
        if '1' * j in A:
            a = j
        else:
            b = j
        if b - a < 3:
            break
    return b

i = N

onecnt = 0
while i > 0:
    i = search_one()
    found = False
    while found == False and i > 0:
        o = A.count('1' * i)
        if o > 0:
            onecnt += (i * (i + 1) // 2) * o
            A = A.replace('1' * i, '')
            found = True
        else:
            i -= 1
    
print(all - onecnt)
0