結果
| 問題 |
No.204 ゴールデン・ウィーク(2)
|
| コンテスト | |
| ユーザー |
明智重蔵
|
| 提出日時 | 2015-07-26 16:36:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,469 bytes |
| コンパイル時間 | 1,168 ms |
| コンパイル使用メモリ | 108,928 KB |
| 実行使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2024-10-13 13:31:54 |
| 合計ジャッジ時間 | 3,661 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 WA * 11 RE * 5 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
string wkSubStr = DayStr.Substring(I, D);
if (wkSubStr.Contains('x') == false) continue;
var wkCharList = new List<char>();
for (int J = 0; J <= UB; J++) {
if (I <= J && J <= I + D - 1) wkCharList.Add('o');
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;
}
}
明智重蔵