結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 明智重蔵明智重蔵
提出日時 2015-07-26 16:47:18
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 2,700 bytes
コンパイル時間 1,161 ms
コンパイル使用メモリ 108,672 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-04-21 14:46:09
合計ジャッジ時間 4,124 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
18,560 KB
testcase_01 AC 30 ms
18,432 KB
testcase_02 AC 29 ms
18,560 KB
testcase_03 AC 29 ms
18,688 KB
testcase_04 AC 29 ms
18,816 KB
testcase_05 AC 29 ms
18,432 KB
testcase_06 AC 30 ms
18,560 KB
testcase_07 AC 29 ms
18,816 KB
testcase_08 AC 29 ms
18,432 KB
testcase_09 AC 29 ms
18,432 KB
testcase_10 AC 29 ms
18,816 KB
testcase_11 AC 29 ms
18,688 KB
testcase_12 AC 29 ms
18,560 KB
testcase_13 AC 32 ms
18,688 KB
testcase_14 AC 32 ms
18,816 KB
testcase_15 AC 32 ms
18,816 KB
testcase_16 AC 29 ms
18,560 KB
testcase_17 AC 30 ms
18,560 KB
testcase_18 AC 31 ms
18,688 KB
testcase_19 AC 29 ms
18,816 KB
testcase_20 AC 30 ms
18,432 KB
testcase_21 AC 30 ms
18,560 KB
testcase_22 AC 30 ms
18,560 KB
testcase_23 AC 29 ms
18,560 KB
testcase_24 AC 29 ms
18,560 KB
testcase_25 AC 29 ms
18,560 KB
testcase_26 AC 29 ms
18,432 KB
testcase_27 AC 29 ms
18,432 KB
testcase_28 AC 29 ms
18,816 KB
testcase_29 AC 29 ms
18,304 KB
testcase_30 AC 29 ms
18,560 KB
testcase_31 AC 30 ms
18,816 KB
testcase_32 AC 31 ms
18,688 KB
testcase_33 AC 30 ms
18,560 KB
testcase_34 AC 32 ms
18,560 KB
testcase_35 RE -
testcase_36 AC 30 ms
18,688 KB
testcase_37 AC 30 ms
18,560 KB
testcase_38 AC 31 ms
18,432 KB
testcase_39 AC 31 ms
18,432 KB
testcase_40 AC 31 ms
18,688 KB
testcase_41 AC 31 ms
18,816 KB
testcase_42 AC 29 ms
18,432 KB
testcase_43 AC 31 ms
18,688 KB
testcase_44 AC 30 ms
18,688 KB
testcase_45 AC 30 ms
18,688 KB
testcase_46 AC 30 ms
18,560 KB
testcase_47 AC 30 ms
18,432 KB
testcase_48 AC 30 ms
18,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input4";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("oxxoxxo");
            WillReturn.Add("ooooxxo");
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("ooxxxxx");
            WillReturn.Add("ooooooo");
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1");
            WillReturn.Add("oxxxxxo");
            WillReturn.Add("xoxxxxo");
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int D = int.Parse(InputList[0]);
        string DayStr = InputList[1] + InputList[2];

        //前後に有給休暇の日数分の平日を付加
        DayStr = new string('x', D) + DayStr + new string('x', D);
        int UB = DayStr.Length - 1;

        var AnswerKouhoList = new List<string>();
        for (int I = 0; I <= UB; I++) {
            //現在の添字から連続した有給休暇を設定したものが、解候補
            if (I + D - 1 > UB) break;
            if (DayStr[I] != 'x') continue; //平日から開始してない場合

            var wkCharList = new List<char>();

            bool IsSeqHeijitu = true; //現在の添字から連続した平日か?
            for (int J = 0; J <= UB; J++) {
                if (I <= J && J <= I + D - 1) {
                    if (DayStr[J] == 'o') IsSeqHeijitu = false;
                    if (IsSeqHeijitu) wkCharList.Add('o');
                    else wkCharList.Add(DayStr[J]);
                }
                else wkCharList.Add(DayStr[J]);
            }

            AnswerKouhoList.Add(new string(wkCharList.ToArray()));
        }
        //AnswerKouhoList.ForEach(X => Console.WriteLine(X));
        Console.WriteLine(AnswerKouhoList.Max(X => DeriveMaxSeqCnt(X)));
    }

    //String型を引数として、最大のoの連続数を返す
    static int DeriveMaxSeqCnt(string pDayStr)
    {
        int MaxSeqCnt = 0;
        int CurrSeqCnt = 0;

        foreach (char EachChar in pDayStr) {
            if (EachChar == 'o') CurrSeqCnt++; //休日だった場合
            else CurrSeqCnt = 0;//平日だった場合

            if (MaxSeqCnt < CurrSeqCnt)
                MaxSeqCnt = CurrSeqCnt;
        }
        return MaxSeqCnt;
    }
}
0