結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー 明智重蔵明智重蔵
提出日時 2015-07-26 16:51:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 1,000 ms
コード長 2,711 bytes
コンパイル時間 2,405 ms
コンパイル使用メモリ 102,896 KB
実行使用メモリ 23,640 KB
最終ジャッジ日時 2023-08-25 23:45:09
合計ジャッジ時間 7,102 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
23,540 KB
testcase_01 AC 61 ms
21,380 KB
testcase_02 AC 60 ms
23,640 KB
testcase_03 AC 60 ms
21,540 KB
testcase_04 AC 61 ms
21,552 KB
testcase_05 AC 60 ms
21,432 KB
testcase_06 AC 59 ms
21,628 KB
testcase_07 AC 61 ms
23,472 KB
testcase_08 AC 60 ms
21,364 KB
testcase_09 AC 60 ms
21,596 KB
testcase_10 AC 60 ms
21,368 KB
testcase_11 AC 59 ms
21,544 KB
testcase_12 AC 60 ms
23,560 KB
testcase_13 AC 60 ms
21,628 KB
testcase_14 AC 60 ms
23,596 KB
testcase_15 AC 60 ms
21,596 KB
testcase_16 AC 60 ms
21,552 KB
testcase_17 AC 60 ms
23,480 KB
testcase_18 AC 60 ms
21,696 KB
testcase_19 AC 59 ms
19,384 KB
testcase_20 AC 61 ms
21,440 KB
testcase_21 AC 60 ms
21,432 KB
testcase_22 AC 60 ms
21,648 KB
testcase_23 AC 60 ms
21,500 KB
testcase_24 AC 61 ms
21,660 KB
testcase_25 AC 60 ms
21,488 KB
testcase_26 AC 60 ms
21,576 KB
testcase_27 AC 60 ms
21,552 KB
testcase_28 AC 59 ms
21,428 KB
testcase_29 AC 60 ms
21,424 KB
testcase_30 AC 60 ms
21,528 KB
testcase_31 AC 60 ms
21,660 KB
testcase_32 AC 59 ms
19,608 KB
testcase_33 AC 60 ms
19,544 KB
testcase_34 AC 59 ms
21,548 KB
testcase_35 AC 59 ms
19,528 KB
testcase_36 AC 60 ms
21,632 KB
testcase_37 AC 60 ms
23,532 KB
testcase_38 AC 59 ms
21,432 KB
testcase_39 AC 60 ms
21,540 KB
testcase_40 AC 60 ms
21,516 KB
testcase_41 AC 59 ms
21,512 KB
testcase_42 AC 61 ms
21,548 KB
testcase_43 AC 60 ms
21,568 KB
testcase_44 AC 60 ms
21,536 KB
testcase_45 AC 60 ms
21,544 KB
testcase_46 AC 60 ms
21,428 KB
testcase_47 AC 60 ms
21,548 KB
testcase_48 AC 60 ms
23,412 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>() { DayStr };
        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