結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー mban
提出日時 2017-01-12 17:56:21
言語 C#
結果
WA  
実行時間 -
コード長 2305 Byte
コンパイル時間 317 ms
使用メモリ 12968 KB

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
challenge01.txt AC 30 ms
12956 KB
challenge02.txt WA -
challenge03.txt WA -
sample1.txt AC 30 ms
12948 KB
sample2.txt AC 31 ms
12960 KB
sample3.txt AC 29 ms
12948 KB
system_test1.txt AC 30 ms
12952 KB
system_test2.txt AC 29 ms
12952 KB
system_test3.txt AC 29 ms
12948 KB
system_test4.txt AC 29 ms
12952 KB
system_test5.txt WA -
system_test6.txt AC 30 ms
12948 KB
system_test7.txt AC 30 ms
12952 KB
system_test8.txt WA -
system_test9.txt WA -
system_test10.txt AC 29 ms
12956 KB
system_test11.txt AC 31 ms
12960 KB
system_test12.txt AC 30 ms
12948 KB
system_test13.txt AC 30 ms
12948 KB
system_test14.txt AC 31 ms
12948 KB
system_test15.txt AC 31 ms
12952 KB
system_test16.txt AC 30 ms
12952 KB
system_test17.txt AC 30 ms
12964 KB
system_test18.txt WA -
system_test19.txt WA -
test1.txt AC 31 ms
12948 KB
test2.txt AC 29 ms
12952 KB
test3.txt AC 30 ms
12948 KB
test4.txt AC 30 ms
12952 KB
test5.txt AC 29 ms
12960 KB
test6.txt AC 32 ms
12948 KB
test7.txt AC 29 ms
12948 KB
test8.txt AC 29 ms
12944 KB
test9.txt AC 30 ms
12948 KB
test10.txt AC 29 ms
12956 KB
test11.txt AC 29 ms
12948 KB
test12.txt AC 29 ms
12948 KB
test13.txt AC 28 ms
12944 KB
test14.txt AC 29 ms
12956 KB
test15.txt AC 27 ms
12948 KB
test16.txt AC 30 ms
12948 KB
test17.txt AC 28 ms
12968 KB
test18.txt AC 28 ms
12956 KB
test19.txt WA -
test20.txt AC 29 ms
12948 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])
          //  {
           //     return -1;
           // }
            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