結果

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

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
challenge01.txt AC 30 ms
8924 KB
challenge02.txt AC 29 ms
8928 KB
challenge03.txt AC 29 ms
8924 KB
sample1.txt AC 27 ms
8912 KB
sample2.txt AC 33 ms
8924 KB
sample3.txt AC 29 ms
8920 KB
system_test1.txt AC 29 ms
8920 KB
system_test2.txt AC 27 ms
8920 KB
system_test3.txt AC 28 ms
8916 KB
system_test4.txt AC 29 ms
8916 KB
system_test5.txt AC 27 ms
8924 KB
system_test6.txt AC 30 ms
10956 KB
system_test7.txt AC 28 ms
8920 KB
system_test8.txt AC 27 ms
8912 KB
system_test9.txt AC 28 ms
8920 KB
system_test10.txt AC 29 ms
10936 KB
system_test11.txt AC 28 ms
8920 KB
system_test12.txt AC 28 ms
8916 KB
system_test13.txt AC 27 ms
8916 KB
system_test14.txt AC 28 ms
8916 KB
system_test15.txt AC 28 ms
8920 KB
system_test16.txt AC 27 ms
8924 KB
system_test17.txt AC 28 ms
8924 KB
system_test18.txt AC 27 ms
8920 KB
system_test19.txt WA -
test1.txt AC 27 ms
8924 KB
test2.txt AC 27 ms
8924 KB
test3.txt AC 29 ms
8912 KB
test4.txt AC 27 ms
8920 KB
test5.txt AC 27 ms
8908 KB
test6.txt AC 27 ms
8912 KB
test7.txt AC 26 ms
8916 KB
test8.txt AC 28 ms
8916 KB
test9.txt AC 28 ms
8908 KB
test10.txt AC 26 ms
8916 KB
test11.txt AC 28 ms
8920 KB
test12.txt AC 28 ms
8908 KB
test13.txt WA -
test14.txt AC 28 ms
8908 KB
test15.txt AC 28 ms
8908 KB
test16.txt AC 29 ms
8916 KB
test17.txt AC 27 ms
8936 KB
test18.txt AC 26 ms
8928 KB
test19.txt AC 29 ms
8924 KB
test20.txt WA -
テストケース一括ダウンロード

ソースコード

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