結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー mban
提出日時 2017-01-12 17:57:02
言語 C#
(mono 5.2.0)
結果
AC  
実行時間 37 ms
コード長 2293 Byte
コンパイル時間 300 ms
使用メモリ 9076 KB

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
challenge01.txt AC 24 ms
9048 KB
challenge02.txt AC 32 ms
9072 KB
challenge03.txt AC 25 ms
9060 KB
sample1.txt AC 24 ms
9052 KB
sample2.txt AC 24 ms
9056 KB
sample3.txt AC 25 ms
9060 KB
system_test1.txt AC 24 ms
9052 KB
system_test2.txt AC 25 ms
9044 KB
system_test3.txt AC 25 ms
9056 KB
system_test4.txt AC 26 ms
9044 KB
system_test5.txt AC 24 ms
9072 KB
system_test6.txt AC 25 ms
9048 KB
system_test7.txt AC 24 ms
9056 KB
system_test8.txt AC 25 ms
9064 KB
system_test9.txt AC 24 ms
9056 KB
system_test10.txt AC 35 ms
9060 KB
system_test11.txt AC 25 ms
9068 KB
system_test12.txt AC 26 ms
9056 KB
system_test13.txt AC 26 ms
9044 KB
system_test14.txt AC 26 ms
9056 KB
system_test15.txt AC 25 ms
9056 KB
system_test16.txt AC 25 ms
9052 KB
system_test17.txt AC 25 ms
9068 KB
system_test18.txt AC 24 ms
9076 KB
system_test19.txt AC 25 ms
9068 KB
system_test20.txt AC 23 ms
9052 KB
system_test21.txt AC 27 ms
9068 KB
system_test22.txt AC 24 ms
9056 KB
test1.txt AC 24 ms
9056 KB
test2.txt AC 24 ms
9056 KB
test3.txt AC 26 ms
9056 KB
test4.txt AC 24 ms
9060 KB
test5.txt AC 24 ms
9048 KB
test6.txt AC 23 ms
9052 KB
test7.txt AC 25 ms
9044 KB
test8.txt AC 37 ms
9052 KB
test9.txt AC 24 ms
9056 KB
test10.txt AC 25 ms
9056 KB
test11.txt AC 25 ms
9048 KB
test12.txt AC 25 ms
9044 KB
test13.txt AC 25 ms
9060 KB
test14.txt AC 25 ms
9048 KB
test15.txt AC 24 ms
9040 KB
test16.txt AC 26 ms
9052 KB
test17.txt AC 24 ms
9060 KB
test18.txt AC 26 ms
9064 KB
test19.txt AC 24 ms
9056 KB
test20.txt AC 25 ms
9056 KB
テストケース一括ダウンロード

ソースコード

diff #
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static private Magatro M = new Magatro();
    static private void Main(string[]args)
    {
        M.Scan();
        M.Solve();
    }
}

public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;

    public Scanner(char separator = ' ')
    {
        Index = 0;
        Separator = separator;
    }

    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (S == null || Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}

public class Magatro
{
    private int D;
    private bool[] C;
    public void Scan()
    {
        Scanner sc = new Scanner();
        D = sc.NextInt();
        C = new bool[15 + D * 2];
        for(int i = 0; i < 2; i++)
        {
            string line = sc.Next();
            for(int j = 0; j < 7; j++)
            {
                C[i * 7 + j + D] = line[j] == 'o';
            }

        }
    }

    public void Solve()
    {
        int ans = 0;
     for(int i = 0; i < C.Length - D; i++)
        {
            ans = Math.Max(ans, Count(i));
        }
        Console.WriteLine(ans);
    }
    private int Count(int index)
    {
        bool[] cp = C.ToArray();
        for(int i = index; i < index + D; i++)
        {
            if (cp[i])
            {
                break;
            }
            cp[i] = true;
        }
        int cnt = 0;
        int result = 0;
        for(int i = 0; i < cp.Length; i++)
        {
            if (cp[i]) cnt++;
            else
            {
                result = Math.Max(result, cnt);
                cnt = 0;
            }
        }
        result = Math.Max(result, cnt);
        return result;
    }
}
0