結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-16 23:33:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,460 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 67,804 KB
実行使用メモリ 24,508 KB
最終ジャッジ日時 2023-08-23 16:50:04
合計ジャッジ時間 5,984 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,672 KB
testcase_01 AC 56 ms
20,704 KB
testcase_02 AC 55 ms
20,748 KB
testcase_03 AC 56 ms
22,844 KB
testcase_04 AC 56 ms
22,644 KB
testcase_05 AC 65 ms
22,604 KB
testcase_06 AC 66 ms
24,408 KB
testcase_07 AC 56 ms
20,620 KB
testcase_08 AC 62 ms
19,588 KB
testcase_09 AC 64 ms
22,084 KB
testcase_10 AC 70 ms
24,508 KB
testcase_11 AC 70 ms
24,472 KB
testcase_12 AC 57 ms
22,660 KB
testcase_13 AC 59 ms
22,628 KB
testcase_14 AC 68 ms
22,088 KB
testcase_15 AC 60 ms
20,732 KB
testcase_16 AC 64 ms
22,424 KB
testcase_17 AC 56 ms
22,632 KB
testcase_18 AC 57 ms
20,688 KB
testcase_19 AC 63 ms
22,324 KB
testcase_20 AC 63 ms
21,712 KB
testcase_21 AC 62 ms
23,476 KB
testcase_22 AC 64 ms
22,520 KB
testcase_23 AC 56 ms
20,808 KB
testcase_24 AC 57 ms
22,768 KB
testcase_25 AC 63 ms
21,584 KB
testcase_26 AC 65 ms
22,476 KB
testcase_27 AC 57 ms
20,804 KB
testcase_28 AC 63 ms
23,964 KB
testcase_29 AC 58 ms
20,664 KB
testcase_30 AC 61 ms
21,588 KB
testcase_31 AC 58 ms
20,892 KB
testcase_32 AC 57 ms
20,600 KB
testcase_33 AC 57 ms
20,696 KB
testcase_34 AC 58 ms
20,604 KB
testcase_35 AC 60 ms
21,280 KB
testcase_36 AC 59 ms
20,680 KB
testcase_37 AC 60 ms
21,184 KB
testcase_38 AC 58 ms
20,612 KB
testcase_39 AC 60 ms
21,348 KB
testcase_40 AC 60 ms
21,320 KB
testcase_41 AC 60 ms
21,484 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();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var s = ReadLine();

        var c0 = 0;
        var c1 = 0;
        var c2 = 0;
        var o0 = 0;
        var o1 = 0;
        var o2 = 0;
        var n0 = 0;
        var n1 = 0;
        var n2 = 0;
        for (var i = 0; i < n; ++i)
        {
            if (s[i * 3] == 'c') ++c0;
            if (s[i * 3] == 'o') ++o0;
            if (s[i * 3] == 'n') ++n0;
            if (s[i * 3 + 1] == 'c') ++c1;
            if (s[i * 3 + 1] == 'o') ++o1;
            if (s[i * 3 + 1] == 'n') ++n1;
            if (s[i * 3 + 2] == 'c') ++c2;
            if (s[i * 3 + 2] == 'o') ++o2;
            if (s[i * 3 + 2] == 'n') ++n2;
        }
        var con = Math.Min(c0, Math.Min(o1, n2));
        var onc = Math.Min(o0, Math.Min(n1, c2));
        var nco = Math.Min(n0, Math.Min(c1, o2));
        var res = con;
        res = Math.Max(res, Math.Min(n - 1, con + onc + nco));
        WriteLine(res);
    }
}
0