結果

問題 No.150 "良問"(良問とは言っていない
ユーザー silviasetitechsilviasetitech
提出日時 2020-03-15 16:11:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 221 ms / 5,000 ms
コード長 1,700 bytes
コンパイル時間 2,260 ms
コンパイル使用メモリ 77,288 KB
実行使用メモリ 41,872 KB
最終ジャッジ日時 2024-05-03 22:20:25
合計ジャッジ時間 6,884 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 187 ms
41,684 KB
testcase_01 AC 132 ms
41,240 KB
testcase_02 AC 132 ms
41,560 KB
testcase_03 AC 131 ms
41,356 KB
testcase_04 AC 129 ms
41,360 KB
testcase_05 AC 136 ms
41,616 KB
testcase_06 AC 221 ms
41,604 KB
testcase_07 AC 132 ms
41,132 KB
testcase_08 AC 132 ms
41,872 KB
testcase_09 AC 135 ms
41,356 KB
testcase_10 AC 211 ms
41,480 KB
testcase_11 AC 195 ms
41,332 KB
testcase_12 AC 189 ms
41,484 KB
testcase_13 AC 217 ms
41,860 KB
testcase_14 AC 216 ms
41,504 KB
testcase_15 AC 186 ms
41,132 KB
testcase_16 AC 137 ms
40,680 KB
testcase_17 AC 179 ms
41,636 KB
testcase_18 AC 195 ms
41,608 KB
testcase_19 AC 200 ms
41,588 KB
testcase_20 AC 176 ms
40,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        goooodProblem solver = new goooodProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class goooodProblem {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int q = in.nextInt();
            for (int i = 0; i < q; i++) {
                out.println(calc(in.next()));
            }
        }

        int calc(String s) {
            int res = Integer.MAX_VALUE;
            for (int i = 0; i <= s.length() - 11; i++) {
                for (int j = i + 4; j <= s.length() - 7; j++) {
                    int cmp = 0;

                    String good = "good";
                    String problem = "problem";
                    for (int k = 0; k < 4; k++) {
                        if (s.charAt(i + k) != good.charAt(k)) {
                            cmp++;
                        }
                    }
                    for (int k = 0; k < 7; k++) {
                        if (s.charAt(j + k) != problem.charAt(k)) {
                            cmp++;
                        }
                    }
                    res = Math.min(res, cmp);
                }
            }
            return res;
        }

    }
}

0