結果

問題 No.150 "良問"(良問とは言っていない
ユーザー kou6839kou6839
提出日時 2015-02-23 17:02:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 204 ms / 5,000 ms
コード長 633 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 74,600 KB
実行使用メモリ 54,828 KB
最終ジャッジ日時 2024-04-19 09:24:03
合計ジャッジ時間 6,424 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 187 ms
54,828 KB
testcase_01 AC 124 ms
53,832 KB
testcase_02 AC 127 ms
54,260 KB
testcase_03 AC 117 ms
53,144 KB
testcase_04 AC 123 ms
54,252 KB
testcase_05 AC 124 ms
54,072 KB
testcase_06 AC 196 ms
54,644 KB
testcase_07 AC 128 ms
54,004 KB
testcase_08 AC 116 ms
52,856 KB
testcase_09 AC 134 ms
54,488 KB
testcase_10 AC 171 ms
54,500 KB
testcase_11 AC 170 ms
54,712 KB
testcase_12 AC 182 ms
54,616 KB
testcase_13 AC 203 ms
54,344 KB
testcase_14 AC 180 ms
54,704 KB
testcase_15 AC 171 ms
54,776 KB
testcase_16 AC 163 ms
54,316 KB
testcase_17 AC 161 ms
54,596 KB
testcase_18 AC 185 ms
54,496 KB
testcase_19 AC 204 ms
54,532 KB
testcase_20 AC 191 ms
54,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String good = "good";
		String problem="problem";
		for(int i=0;i<n;i++){
			String moto = sc.next();
			int ans=11;
			for(int j=0;j<=moto.length()-11;j++){
				for(int k=j+4;k<=moto.length()-7;k++){
					int count=0;
					for(int l=0;l<=3;l++){
						if(moto.charAt(j+l)!=good.charAt(l))count++;
					}
					for(int l=0;l<=6;l++){
						if(moto.charAt(k+l)!=problem.charAt(l))count++;
					}
					ans=Math.min(ans, count);
				}
			}
			System.out.println(ans);
		}
	}
}
0