結果
| 問題 | No.2076 Concon Substrings (ConVersion) |
| コンテスト | |
| ユーザー |
AngrySadEight
|
| 提出日時 | 2022-09-06 23:46:56 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,655 bytes |
| 記録 | |
| コンパイル時間 | 764 ms |
| コンパイル使用メモリ | 78,884 KB |
| 最終ジャッジ日時 | 2025-02-07 03:16:14 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 WA * 1 |
ソースコード
#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 len = rle.size();
int INF = N / 3 + 1;
int MAX_J = N / 6 + 1;
vector<int> divA(INF);
for (int i = 0; i < INF; i++){
divA[i] = i / A;
}
vector<int> divB(INF);
for (int i = 0; i < INF; i++){
divB[i] = i / B;
}
vector<int> dp1(MAX_J, -INF);
vector<int> dp2(MAX_J, -INF);
dp1[0] = 0;
int count = 0;
for (int i = 0; i < len; i++){
count += divA[rle[i]];
for (int j = 0; j <= count; j++){
for (int k = 0; k <= divA[rle[i]]; k++){
if (j + k >= MAX_J) continue;
dp2[j + k] = max(dp2[j + k], dp1[j] + divB[rle[i] - A * k]);
}
}
for (int j = 0; j < MAX_J; j++){
dp1[j] = dp2[j];
dp2[j] = -INF;
}
}
int ans = 0;
for (int j = 0; j < MAX_J; j++){
if (dp1[j] >= j - 1) ans = max(ans, 2 * j - 1);
if (dp1[j] >= j) ans = max(ans, 2 * j);
}
cout << ans << endl;
}
AngrySadEight