結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-09-07 00:16:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,560 ms / 5,000 ms
コード長 1,227 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 86,524 KB
実行使用メモリ 77,432 KB
最終ジャッジ日時 2023-08-23 16:58:38
合計ジャッジ時間 23,337 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
70,732 KB
testcase_01 AC 68 ms
70,940 KB
testcase_02 AC 67 ms
71,124 KB
testcase_03 AC 69 ms
70,928 KB
testcase_04 AC 71 ms
70,948 KB
testcase_05 AC 3,560 ms
76,884 KB
testcase_06 AC 78 ms
75,616 KB
testcase_07 AC 2,962 ms
77,312 KB
testcase_08 AC 1,937 ms
77,316 KB
testcase_09 AC 3,018 ms
77,388 KB
testcase_10 AC 70 ms
70,828 KB
testcase_11 AC 72 ms
70,924 KB
testcase_12 AC 70 ms
71,132 KB
testcase_13 AC 69 ms
70,832 KB
testcase_14 AC 68 ms
71,128 KB
testcase_15 AC 2,330 ms
77,360 KB
testcase_16 AC 730 ms
77,240 KB
testcase_17 AC 456 ms
77,408 KB
testcase_18 AC 2,493 ms
77,388 KB
testcase_19 AC 217 ms
77,332 KB
testcase_20 AC 1,833 ms
77,432 KB
testcase_21 AC 68 ms
71,188 KB
testcase_22 AC 225 ms
77,204 KB
testcase_23 AC 101 ms
76,976 KB
testcase_24 AC 99 ms
76,848 KB
testcase_25 AC 102 ms
77,416 KB
testcase_26 AC 118 ms
77,092 KB
testcase_27 AC 187 ms
77,324 KB
testcase_28 AC 118 ms
77,192 KB
testcase_29 AC 190 ms
77,164 KB
testcase_30 AC 146 ms
77,316 KB
testcase_31 AC 72 ms
70,856 KB
権限があれば一括ダウンロードができます

ソースコード

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 = N // 3 + 1
MAX_J = (N + 3) // 6 + 1
divA = [0 for _ in range(INF)]
divB = [0 for _ in range(INF)]
for i in range(INF):
    divA[i] = i // A
    divB[i] = i // B
dp1 = [-INF for _ in range(MAX_J)]
dp2 = [-INF for _ in range(MAX_J)]
dp1[0] = 0
now = 0
for i in range(len(rle)):
    now += divA[rle[i]]
    for j in range(now + 1):
        for k in range(divA[rle[i]] + 1):
            if j + k >= MAX_J:
                continue
            val = divB[rle[i] - A * k]
            if dp2[j + k] < dp1[j] + val:
                dp2[j + k] = dp1[j] + val
    for j in range(now + 1):
        if j >= MAX_J:
            continue
        dp1[j] = dp2[j]
        dp2[j] = -INF
    #print(dp1[0:5])
ans = 0
for j in range(MAX_J):
    if dp1[j] >= j - 1:
        ans = max(ans, 2 * j - 1)
    if dp1[j] >= j:
        ans = max(ans, 2 * j)
print(ans)
0