結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-08-24 14:09:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,018 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 76,892 KB
最終ジャッジ日時 2024-04-20 14:13:32
合計ジャッジ時間 17,458 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 43 ms
58,632 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 43 ms
61,276 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 39 ms
59,032 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, A, B = map(int, input().split())
S = str(input())
rle = []
concnt = 0
now_idx = 0
while True:
    if now_idx >= N - 2:
        if concnt >= 1:
            rle.append(concnt)
        break
    elif S[now_idx:(now_idx + 3)] == 'con':
        now_idx += 3
        concnt += 1
    else:
        now_idx += 1
        if concnt >= 1:
            rle.append(concnt)
        concnt = 0

INF = -50000
dp1 = [INF for _ in range(8338)]
dp2 = [INF for _ in range(8338)]
dp1[0] = 0
now = 0
for i in range(len(rle)):
    now += rle[i] // A
    for j in range(now + 1):
        for k in range(rle[i] // A + 1):
            if j + k >= 8338:
                continue
            val = (rle[i] - A * k) // B
            if dp2[j + k] > dp1[j] + val:
                dp2[j + k] = dp1[j] + val
    for j in range(8338):
        dp1[j] = dp2[j]
        dp2[j] = INF
    #print(dp1[0:5])
ans = 0
for j in range(8338):
    if dp1[j] >= j - 1:
        ans = max(ans, 2 * j - 1)
    if dp1[j] >= j:
        ans = max(ans, 2 * j)
print(ans)
0