結果

問題 No.2298 yukicounter
ユーザー kakel-san
提出日時 2023-07-27 08:43:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 995 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 111,380 KB
実行使用メモリ 26,192 KB
最終ジャッジ日時 2024-10-04 00:52:57
合計ジャッジ時間 3,275 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var s = ReadLine();
        var ans = 0;
        var tmp = 0;
        for (var i = 0; i < s.Length; ++i)
        {
            if (IsYuki(i, s))
            {
                ++tmp;
                i += yuki.Length - 1;
            }
            else tmp = 0;
            ans = Math.Max(ans, tmp);
        }
        WriteLine(ans);
    }
    static string yuki = "yukicoder";
    static bool IsYuki(int pos, string s)
    {
        if (pos + yuki.Length > s.Length) return false;
        for (var i = 0; i < yuki.Length; ++i)
        {
            if (yuki[i] != s[pos + i]) return false;
        }
        return true;
    }
}
0