結果

問題 No.2276 I Want AC
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-07 21:25:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 1,164 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 69,832 KB
実行使用メモリ 24,168 KB
最終ジャッジ日時 2023-09-28 22:20:57
合計ジャッジ時間 10,197 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
22,700 KB
testcase_01 AC 55 ms
20,744 KB
testcase_02 AC 54 ms
20,640 KB
testcase_03 AC 55 ms
22,684 KB
testcase_04 AC 58 ms
20,552 KB
testcase_05 AC 56 ms
20,728 KB
testcase_06 AC 55 ms
20,668 KB
testcase_07 AC 55 ms
20,740 KB
testcase_08 AC 55 ms
20,640 KB
testcase_09 AC 56 ms
22,668 KB
testcase_10 AC 54 ms
20,628 KB
testcase_11 AC 58 ms
20,740 KB
testcase_12 AC 65 ms
23,840 KB
testcase_13 AC 59 ms
20,624 KB
testcase_14 AC 57 ms
20,660 KB
testcase_15 AC 61 ms
23,072 KB
testcase_16 AC 61 ms
18,956 KB
testcase_17 AC 64 ms
23,712 KB
testcase_18 AC 62 ms
21,244 KB
testcase_19 AC 56 ms
20,648 KB
testcase_20 AC 65 ms
22,016 KB
testcase_21 AC 59 ms
22,848 KB
testcase_22 AC 57 ms
22,764 KB
testcase_23 AC 66 ms
22,036 KB
testcase_24 AC 66 ms
20,048 KB
testcase_25 AC 66 ms
24,164 KB
testcase_26 AC 63 ms
22,040 KB
testcase_27 AC 64 ms
22,036 KB
testcase_28 AC 63 ms
24,132 KB
testcase_29 AC 65 ms
24,080 KB
testcase_30 AC 65 ms
24,048 KB
testcase_31 AC 63 ms
24,024 KB
testcase_32 AC 64 ms
21,992 KB
testcase_33 AC 63 ms
20,004 KB
testcase_34 AC 66 ms
24,048 KB
testcase_35 AC 60 ms
23,700 KB
testcase_36 AC 61 ms
21,644 KB
testcase_37 AC 61 ms
22,048 KB
testcase_38 AC 60 ms
22,084 KB
testcase_39 AC 64 ms
22,028 KB
testcase_40 AC 62 ms
24,016 KB
testcase_41 AC 61 ms
22,008 KB
testcase_42 AC 62 ms
24,048 KB
testcase_43 AC 63 ms
22,000 KB
testcase_44 AC 64 ms
21,552 KB
testcase_45 AC 63 ms
24,100 KB
testcase_46 AC 66 ms
24,052 KB
testcase_47 AC 65 ms
22,020 KB
testcase_48 AC 66 ms
24,084 KB
testcase_49 AC 63 ms
22,092 KB
testcase_50 AC 65 ms
22,000 KB
testcase_51 AC 67 ms
21,984 KB
testcase_52 AC 69 ms
22,040 KB
testcase_53 AC 63 ms
22,048 KB
testcase_54 AC 63 ms
20,064 KB
testcase_55 AC 62 ms
23,996 KB
testcase_56 AC 64 ms
24,100 KB
testcase_57 AC 62 ms
24,168 KB
testcase_58 AC 65 ms
24,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var s = ReadLine();

        var sc = s.Replace('?', 'C');
        var acount = 0;
        var tmp = 0L;
        for (var i = 0; i < n; ++i)
        {
            if (sc[i] == 'A') ++acount;
            else tmp += acount;
        }
        var ccount = new int[n];
        for (var i = n - 1; i >= 0; --i)
        {
            if (i < n - 1) ccount[i] = ccount[i + 1];
            if (sc[i] != 'A') ++ccount[i];
        }
        acount = 0;
        var max = tmp;
        for (var i = 0; i < n; ++i)
        {
            if (s[i] == 'A') ++acount;
            if (s[i] == '?')
            {
                tmp = tmp - acount + ccount[i] - 1;
                ++acount;
                max = Math.Max(max, tmp);
            }
        }
        WriteLine(max);
    }
}
0