結果

問題 No.150 "良問"(良問とは言っていない
ユーザー bluemeganebluemegane
提出日時 2018-10-02 16:59:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 1,061 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 110,008 KB
実行使用メモリ 25,816 KB
最終ジャッジ日時 2024-04-19 09:48:36
合計ジャッジ時間 2,034 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,904 KB
testcase_01 AC 23 ms
25,556 KB
testcase_02 AC 23 ms
23,776 KB
testcase_03 AC 23 ms
25,804 KB
testcase_04 AC 23 ms
23,648 KB
testcase_05 AC 23 ms
25,568 KB
testcase_06 AC 34 ms
23,732 KB
testcase_07 AC 23 ms
23,768 KB
testcase_08 AC 22 ms
23,900 KB
testcase_09 AC 23 ms
25,816 KB
testcase_10 AC 26 ms
23,772 KB
testcase_11 AC 26 ms
25,812 KB
testcase_12 AC 24 ms
25,816 KB
testcase_13 AC 27 ms
25,808 KB
testcase_14 AC 27 ms
25,812 KB
testcase_15 AC 26 ms
25,812 KB
testcase_16 AC 24 ms
23,776 KB
testcase_17 AC 24 ms
25,676 KB
testcase_18 AC 26 ms
23,648 KB
testcase_19 AC 27 ms
25,812 KB
testcase_20 AC 27 ms
23,396 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            Console.WriteLine(getAns(s));
        }
    }
    public static int getAns (string s)
    {
        var a = "good";
        var ans = int.MaxValue;
        for (int i = 0; i <= s.Length - 11; i++)
        {
            var count = 0;
            for (int j = 0; j < 4; j++)
                if (a[j] != s[i + j]) count++;
            var w = getAnsP(s, i + 4);
            count += w;
            ans = Math.Min(ans, count);
        }
        return ans;
    }
    public static int getAnsP(string s, int st)
    {
        var a = "problem";
        var cmin = int.MaxValue;
        for (int i = st; i <= s.Length - 7; i++)
        {
            var count = 0;
            for (int j = 0; j < 7; j++)
                if (a[j] != s[i  +  j]) count++;
            cmin = Math.Min(cmin, count);
        }
        return cmin;
    }
}
0