結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー 👑 rin204rin204
提出日時 2022-09-16 22:12:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 86,652 KB
実行使用メモリ 78,036 KB
最終ジャッジ日時 2023-08-23 15:47:58
合計ジャッジ時間 5,363 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,116 KB
testcase_01 AC 72 ms
71,116 KB
testcase_02 AC 72 ms
71,300 KB
testcase_03 AC 72 ms
71,352 KB
testcase_04 AC 72 ms
71,336 KB
testcase_05 AC 90 ms
76,244 KB
testcase_06 AC 77 ms
75,536 KB
testcase_07 AC 107 ms
77,392 KB
testcase_08 AC 107 ms
77,368 KB
testcase_09 AC 107 ms
77,252 KB
testcase_10 AC 74 ms
70,968 KB
testcase_11 AC 75 ms
71,276 KB
testcase_12 WA -
testcase_13 AC 74 ms
71,312 KB
testcase_14 AC 74 ms
71,184 KB
testcase_15 AC 99 ms
77,152 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 114 ms
77,272 KB
testcase_20 WA -
testcase_21 AC 71 ms
71,336 KB
testcase_22 WA -
testcase_23 AC 86 ms
76,088 KB
testcase_24 AC 87 ms
76,208 KB
testcase_25 WA -
testcase_26 AC 94 ms
76,384 KB
testcase_27 AC 103 ms
77,048 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 99 ms
77,360 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()

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

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

ans = f(aa, bb)
for i in range(aa - 1, -1, -1):
    c = -heappop(C)
    c += a
    bb += c // b
    c %= b
    heappush(C, -c)
    ans = max(ans, f(i, bb))


print(ans)
0