結果

問題 No.2076 Concon Substrings (ConVersion)
ユーザー 👑 NachiaNachia
提出日時 2022-09-16 22:03:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 577 ms / 5,000 ms
コード長 1,386 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 84,072 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 16:59:37
合計ジャッジ時間 5,066 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 107 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 577 ms
4,376 KB
testcase_08 AC 462 ms
4,380 KB
testcase_09 AC 577 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 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,376 KB
testcase_15 AC 224 ms
4,380 KB
testcase_16 AC 107 ms
4,376 KB
testcase_17 AC 45 ms
4,380 KB
testcase_18 AC 412 ms
4,376 KB
testcase_19 AC 28 ms
4,380 KB
testcase_20 AC 302 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 25 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 13 ms
4,380 KB
testcase_28 AC 8 ms
4,376 KB
testcase_29 AC 19 ms
4,376 KB
testcase_30 AC 15 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <atcoder/modint>

using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using Modint = atcoder::static_modint<998244353>;


int main(){
    int N,A,B; cin >> N >> A >> B;
    string S; cin >> S;

    vector<int> ConCon = {0};
    while(S.size() >= 3){
        if(S.substr(S.size() - 3) == "con"){
            S.resize(S.size() - 3);
            ConCon.back()++;
            continue;
        }
        if(ConCon.back() != 0) ConCon.push_back(0);
        S.pop_back();
    }
    if(ConCon.back() == 0) ConCon.pop_back();
    
    vector<int> Q(N/3/A+1, -1001001001);
    Q[0] = 0;
    for(int s : ConCon){
        vector<int> bV;
        for(int a=0; a*A<=s; a++) bV.push_back((s-a*A)/B);
        for(int q=Q.size()-1; q>=0; q--){
            int tmp = -1001001001;
            for(int a=min((int)bV.size()-1,q); a>=0; a--) tmp = max(tmp, Q[q-a] + bV[a]);
            Q[q] = tmp;
        }
    }

    int ans = 0;
    rep(i,Q.size()) if(Q[i] >= 0) ans = max(ans, min(i*2,Q[i]*2+1));
    cout << ans << '\n';
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0