結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー AngrySadEightAngrySadEight
提出日時 2022-08-24 13:57:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,669 ms / 5,000 ms
コード長 1,393 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 75,064 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 16:52:38
合計ジャッジ時間 13,522 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 546 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 1,644 ms
4,384 KB
testcase_08 AC 1,310 ms
4,380 KB
testcase_09 AC 1,669 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 936 ms
4,376 KB
testcase_16 AC 635 ms
4,376 KB
testcase_17 AC 432 ms
4,380 KB
testcase_18 AC 1,258 ms
4,380 KB
testcase_19 AC 341 ms
4,376 KB
testcase_20 AC 1,084 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 301 ms
4,380 KB
testcase_23 AC 116 ms
4,380 KB
testcase_24 AC 134 ms
4,376 KB
testcase_25 AC 152 ms
4,376 KB
testcase_26 AC 133 ms
4,380 KB
testcase_27 AC 200 ms
4,376 KB
testcase_28 AC 170 ms
4,380 KB
testcase_29 AC 265 ms
4,376 KB
testcase_30 AC 257 ms
4,376 KB
testcase_31 AC 5 ms
4,380 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;
    for (int i = 0; i < len; i++){
        for (int j = 0; j < 8336; 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