結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,348 KB
testcase_01 AC 34 ms
53,068 KB
testcase_02 AC 35 ms
52,280 KB
testcase_03 AC 53 ms
65,160 KB
testcase_04 AC 43 ms
61,516 KB
testcase_05 AC 1,872 ms
75,076 KB
testcase_06 TLE -
testcase_07 AC 1,116 ms
69,740 KB
testcase_08 AC 1,600 ms
72,228 KB
testcase_09 AC 1,397 ms
71,332 KB
testcase_10 AC 39 ms
56,464 KB
testcase_11 AC 40 ms
57,804 KB
testcase_12 AC 37 ms
55,864 KB
testcase_13 AC 42 ms
58,252 KB
testcase_14 AC 42 ms
57,428 KB
testcase_15 AC 44 ms
61,924 KB
testcase_16 AC 101 ms
68,556 KB
testcase_17 AC 109 ms
69,280 KB
testcase_18 AC 106 ms
67,824 KB
testcase_19 AC 33 ms
52,688 KB
testcase_20 AC 34 ms
52,216 KB
testcase_21 AC 33 ms
53,096 KB
testcase_22 AC 105 ms
68,128 KB
testcase_23 AC 105 ms
68,728 KB
testcase_24 AC 102 ms
68,308 KB
testcase_25 AC 100 ms
66,256 KB
testcase_26 AC 102 ms
68,188 KB
testcase_27 AC 96 ms
66,340 KB
testcase_28 AC 95 ms
68,364 KB
testcase_29 AC 100 ms
68,228 KB
testcase_30 AC 97 ms
67,616 KB
testcase_31 AC 101 ms
68,428 KB
testcase_32 AC 69 ms
60,036 KB
testcase_33 AC 67 ms
60,656 KB
testcase_34 AC 67 ms
60,440 KB
testcase_35 AC 63 ms
59,520 KB
testcase_36 AC 61 ms
58,492 KB
testcase_37 AC 67 ms
60,680 KB
testcase_38 AC 67 ms
59,236 KB
testcase_39 AC 67 ms
60,776 KB
testcase_40 AC 69 ms
60,392 KB
testcase_41 AC 76 ms
61,492 KB
testcase_42 AC 39 ms
53,024 KB
testcase_43 AC 42 ms
54,564 KB
testcase_44 AC 38 ms
53,072 KB
testcase_45 AC 41 ms
53,504 KB
testcase_46 AC 39 ms
53,792 KB
testcase_47 AC 44 ms
54,588 KB
testcase_48 AC 40 ms
53,788 KB
testcase_49 AC 38 ms
52,728 KB
testcase_50 AC 37 ms
53,692 KB
testcase_51 AC 39 ms
53,816 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 < 5:
            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