結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2018-10-02 16:59:00 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 5,000 ms |
| コード長 | 1,061 bytes |
| コンパイル時間 | 770 ms |
| コンパイル使用メモリ | 111,660 KB |
| 実行使用メモリ | 17,664 KB |
| 最終ジャッジ日時 | 2024-10-11 02:14:56 |
| 合計ジャッジ時間 | 2,041 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
}
bluemegane