結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-08-24 13:56:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,385 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 75,244 KB
実行使用メモリ 11,036 KB
最終ジャッジ日時 2024-04-20 14:13:08
合計ジャッジ時間 12,352 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    
    vector<int> rle(0);
    int concnt = 0;
    int now_idx = 0;
    while(true){
        if (now_idx >= N - 2){
            if (concnt >= 1){
                rle.push_back(concnt);
            }
            break;
        }
        else if (S.substr(now_idx, 3) == "con"){
            now_idx += 3;
            concnt++;
        }
        else{
            now_idx++;
            if (concnt >= 1){
                rle.push_back(concnt);
            }
            concnt = 0;
        }
    }
    int INF = 50000;
    int len = rle.size();
    vector<int> dp1(N + 1, INF * -1);
    vector<int> dp2(N + 1, INF * -1);
    dp1[0] = 0;
    for (int i = 0; i < len; i++){
        for (int j = 0; j <= N; j++){
            for (int k = 0; k <= (rle[i] / A); k++){
                if (j + k >= N) continue;
                dp2[j + k] = max(dp2[j + k], dp1[j] + (rle[i] - A * k) / B);
            }
        }
        for (int j = 0; j <= N; j++){
            dp1[j] = dp2[j];
            dp2[j] = INF * -1;
        }
    }
    int ans = 0;
    for (int j = 0; j < N; j++){
        if (dp1[j] >= j - 1) ans = max(ans, 2 * j - 1);
        if (dp1[j] >= j) ans = max(ans, 2 * j);
    }
    cout << ans << endl;
}
0