結果

問題 No.2276 I Want AC
ユーザー tsugutsugutsugutsugu
提出日時 2023-04-21 21:41:32
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,009 bytes
コンパイル時間 3,524 ms
コンパイル使用メモリ 275,576 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-04-24 07:50:47
合計ジャッジ時間 4,855 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 5 ms
6,784 KB
testcase_36 AC 5 ms
6,656 KB
testcase_37 WA -
testcase_38 AC 5 ms
6,656 KB
testcase_39 AC 5 ms
6,656 KB
testcase_40 AC 5 ms
6,784 KB
testcase_41 AC 5 ms
6,784 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 5 ms
6,656 KB
testcase_56 AC 6 ms
6,656 KB
testcase_57 AC 5 ms
6,656 KB
testcase_58 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    cin >> n >> s;
    vector<int> cntA(n + 1, 0), cntC(n + 1, 0);
    vector<int> cntQ(n + 1, 0), cntQ2(n + 1, 0);
    for (int i = 0; i < n; i++) {
        cntA[i + 1] = cntA[i] + (s[i] == 'A');
    }
    for (int i = n - 1; i >= 0; i--) {
        cntC[i] = cntC[i + 1] + (s[i] == 'C');
    }
    for (int i = n - 1; i >= 0; i--) {
        cntQ[i] = cntQ[i + 1] + (s[i] == '?');
    }
    for (int i = 0; i < n; i++) {
        cntQ2[i + 1] = cntQ2[i] + (s[i] == '?');
    }
    int q = 0, ans = 0;
    int cur = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A') {
            cur += cntC[i] + cntQ[i];
        }
    }
    ans = cur;
    for (int i = 0; i < n; i++) {
        if (s[i] == '?') {
            cur -= cntA[i] + cntQ2[i];
            cur += cntQ[i + 1] + cntC[i + 1];
            ans = max(ans, cur);
        }
    }
    cout << ans << '\n';
}
0