結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-08-25 01:40:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,234 ms / 5,000 ms
コード長 1,443 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 79,160 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 16:54:46
合計ジャッジ時間 9,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 939 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 1,226 ms
4,380 KB
testcase_08 AC 817 ms
4,376 KB
testcase_09 AC 1,234 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 824 ms
4,376 KB
testcase_16 AC 246 ms
4,380 KB
testcase_17 AC 139 ms
4,380 KB
testcase_18 AC 926 ms
4,376 KB
testcase_19 AC 50 ms
4,380 KB
testcase_20 AC 913 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 56 ms
4,376 KB
testcase_23 AC 8 ms
4,380 KB
testcase_24 AC 9 ms
4,380 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 14 ms
4,380 KB
testcase_27 AC 39 ms
4,380 KB
testcase_28 AC 15 ms
4,376 KB
testcase_29 AC 42 ms
4,376 KB
testcase_30 AC 27 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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(8336, INF * -1);
    vector<int> dp2(8336, INF * -1);
    dp1[0] = 0;
    int count = 0;
    for (int i = 0; i < len; i++){
        count += rle[i] / A;
        for (int j = 0; j <= count; j++){
            for (int k = 0; k <= (rle[i] / A); k++){
                if (j + k >= 8336) continue;
                dp2[j + k] = max(dp2[j + k], dp1[j] + (rle[i] - A * k) / B);
            }
        }
        for (int j = 0; j < 8336; j++){
            dp1[j] = dp2[j];
            dp2[j] = INF * -1;
        }
    }
    int ans = 0;
    for (int j = 0; j < 8336; 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