結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー kakel-san
提出日時 2022-09-16 23:22:31
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,684 bytes
コンパイル時間 3,406 ms
コンパイル使用メモリ 107,904 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-12-21 22:58:58
合計ジャッジ時間 3,584 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 25 WA * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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, onc));
        res = Math.Max(res, Math.Min(n - 1, nco));
        res = Math.Max(res, Math.Min(n - 1, con + onc));
        res = Math.Max(res, Math.Min(n - 1, con + nco));
        res = Math.Max(res, Math.Min(n - 1, onc + nco));
        res = Math.Max(res, Math.Min(n - 2, con + onc + nco));
        WriteLine(res);
    }
}
0