結果

問題 No.150 "良問"(良問とは言っていない
ユーザー tsunabittsunabit
提出日時 2020-03-08 01:33:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 212 ms / 5,000 ms
コード長 755 bytes
コンパイル時間 3,317 ms
コンパイル使用メモリ 77,552 KB
実行使用メモリ 55,120 KB
最終ジャッジ日時 2024-04-23 15:27:34
合計ジャッジ時間 7,852 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 194 ms
54,356 KB
testcase_01 AC 128 ms
53,980 KB
testcase_02 AC 131 ms
54,304 KB
testcase_03 AC 130 ms
53,980 KB
testcase_04 AC 127 ms
53,960 KB
testcase_05 AC 133 ms
54,036 KB
testcase_06 AC 212 ms
55,120 KB
testcase_07 AC 129 ms
54,328 KB
testcase_08 AC 133 ms
54,272 KB
testcase_09 AC 134 ms
54,188 KB
testcase_10 AC 173 ms
54,104 KB
testcase_11 AC 186 ms
54,424 KB
testcase_12 AC 168 ms
54,540 KB
testcase_13 AC 172 ms
54,428 KB
testcase_14 AC 181 ms
54,708 KB
testcase_15 AC 196 ms
54,092 KB
testcase_16 AC 132 ms
53,284 KB
testcase_17 AC 160 ms
54,180 KB
testcase_18 AC 203 ms
54,680 KB
testcase_19 AC 205 ms
54,632 KB
testcase_20 AC 198 ms
54,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No150 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		String[] s = new String[t];
		for(int i = 0; i < t; i++) s[i] = sc.next();
		for(int i = 0; i < t; i++) {
			int tmpG = 0, tmpP = 0, ans = 100;
			String g = "good", p ="problem";
			for(int j = 0; j < s[i].length()-10; j++) {
				tmpG = 0;
				for(int k = 0; k < 4; k++) {
					if(s[i].charAt(j+k) != g.charAt(k)) tmpG++;
				}
				for(int l = j+4; l < s[i].length()-6; l++) {
					tmpP = 0;
					for(int k = 0; k < 7; k++) {
						if(s[i].charAt(l+k) != p.charAt(k)) tmpP++;
					}
					ans = Math.min(ans, tmpG+tmpP);
				}
			}
			System.out.println(ans);
		}
	}
}
0