結果

問題 No.150 "良問"(良問とは言っていない
ユーザー ぴろずぴろず
提出日時 2015-02-12 23:40:46
言語 Java19
(openjdk 21)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 746 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 71,912 KB
実行使用メモリ 56,560 KB
最終ジャッジ日時 2023-08-01 09:44:46
合計ジャッジ時間 6,297 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
56,416 KB
testcase_01 AC 124 ms
55,640 KB
testcase_02 AC 124 ms
55,588 KB
testcase_03 AC 125 ms
55,732 KB
testcase_04 AC 124 ms
55,516 KB
testcase_05 AC 127 ms
55,596 KB
testcase_06 AC 185 ms
55,980 KB
testcase_07 AC 126 ms
55,708 KB
testcase_08 AC 124 ms
55,788 KB
testcase_09 AC 128 ms
55,876 KB
testcase_10 AC 155 ms
55,976 KB
testcase_11 AC 157 ms
56,044 KB
testcase_12 AC 159 ms
56,272 KB
testcase_13 AC 160 ms
55,856 KB
testcase_14 AC 181 ms
56,560 KB
testcase_15 AC 158 ms
56,096 KB
testcase_16 AC 136 ms
55,584 KB
testcase_17 AC 148 ms
56,036 KB
testcase_18 AC 183 ms
56,316 KB
testcase_19 AC 182 ms
56,252 KB
testcase_20 AC 175 ms
56,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no150;

import java.util.Scanner;

public class Main {
	static char[] good = "good".toCharArray();
	static char[] problem = "problem".toCharArray();
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(int tt=0;tt<t;tt++) {
			char[] s = sc.next().toCharArray();
			int n = s.length;
			int min = n+1;
			for(int i=0;i+3<n;i++) {
				for(int j=i+4;j+6<n;j++) {
					int d = 0;
					for(int k=0;k<4;k++) {
						if (s[i+k] != good[k]) {
							d++;
						}
					}
					for(int k=0;k<7;k++) {
						if (s[j+k] != problem[k]) {
							d++;
						}
					}
//					System.out.println(i + "," + j + "," + d);
					min = Math.min(min,d);

				}
			}
			System.out.println(min);
		}
	}

}
0