結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-09-07 00:15:22
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,183 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 77,736 KB
最終ジャッジ日時 2024-05-01 18:30:27
合計ジャッジ時間 14,381 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,636 KB
testcase_01 AC 39 ms
52,756 KB
testcase_02 AC 37 ms
52,724 KB
testcase_03 AC 36 ms
53,680 KB
testcase_04 AC 36 ms
53,036 KB
testcase_05 RE -
testcase_06 AC 48 ms
62,112 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 37 ms
53,664 KB
testcase_11 AC 38 ms
52,660 KB
testcase_12 AC 37 ms
52,548 KB
testcase_13 AC 38 ms
52,580 KB
testcase_14 AC 38 ms
52,556 KB
testcase_15 RE -
testcase_16 AC 701 ms
76,488 KB
testcase_17 AC 419 ms
76,664 KB
testcase_18 RE -
testcase_19 AC 200 ms
76,628 KB
testcase_20 RE -
testcase_21 AC 37 ms
53,344 KB
testcase_22 AC 201 ms
76,376 KB
testcase_23 AC 75 ms
76,376 KB
testcase_24 AC 70 ms
72,616 KB
testcase_25 AC 70 ms
72,808 KB
testcase_26 AC 95 ms
76,648 KB
testcase_27 RE -
testcase_28 AC 88 ms
76,596 KB
testcase_29 AC 158 ms
76,376 KB
testcase_30 AC 118 ms
76,388 KB
testcase_31 AC 40 ms
53,912 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):
        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