結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー 👑 rin204rin204
提出日時 2022-09-16 22:39:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 86,980 KB
実行使用メモリ 78,812 KB
最終ジャッジ日時 2023-08-23 16:14:28
合計ジャッジ時間 5,486 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,228 KB
testcase_01 AC 75 ms
71,304 KB
testcase_02 AC 76 ms
71,436 KB
testcase_03 AC 73 ms
71,268 KB
testcase_04 AC 74 ms
71,456 KB
testcase_05 AC 88 ms
76,168 KB
testcase_06 AC 77 ms
75,560 KB
testcase_07 AC 116 ms
78,120 KB
testcase_08 AC 113 ms
78,076 KB
testcase_09 AC 116 ms
78,008 KB
testcase_10 AC 74 ms
71,256 KB
testcase_11 AC 74 ms
71,508 KB
testcase_12 AC 73 ms
71,268 KB
testcase_13 AC 73 ms
71,436 KB
testcase_14 AC 73 ms
71,420 KB
testcase_15 AC 109 ms
77,444 KB
testcase_16 AC 151 ms
78,308 KB
testcase_17 AC 144 ms
78,016 KB
testcase_18 AC 189 ms
78,812 KB
testcase_19 WA -
testcase_20 AC 177 ms
78,776 KB
testcase_21 AC 75 ms
71,408 KB
testcase_22 AC 147 ms
78,292 KB
testcase_23 AC 112 ms
77,384 KB
testcase_24 AC 109 ms
77,744 KB
testcase_25 AC 113 ms
77,376 KB
testcase_26 AC 118 ms
77,332 KB
testcase_27 AC 135 ms
78,172 KB
testcase_28 WA -
testcase_29 AC 137 ms
77,780 KB
testcase_30 AC 135 ms
78,428 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

n, a, b = map(int, input().split())
S = input()
S = S.replace("con", "*")
lst = []
row = 0
for s in S:
    if s == "*":
        row += 1
    else:
        if row != 0:
            lst.append(row)
        row = 0
if row != 0:
    lst.append(row)
lst.sort()
tot = sum(lst)

aa = 0
bb = 0
C = []
for l in lst:
    bb += l // b
    C.append((-(l % b), l))

heapify(C)

def f(a, b):
    if a > b:
        return 2 * b + 1
    else:
        return 2 * a

ans = f(aa, bb)

while C:

    _, d = heappop(C)
    if d < a:
        continue
    bb -= d // b
    d -= a
    aa += 1
    bb += d // b
    heappush(C, (-(d % b), d))
    ans = max(ans, f(aa, bb))

print(ans)
0