結果

問題 No.150 "良問"(良問とは言っていない
ユーザー silviasetitechsilviasetitech
提出日時 2020-03-15 16:11:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 1,700 bytes
コンパイル時間 2,105 ms
コンパイル使用メモリ 74,280 KB
実行使用メモリ 56,600 KB
最終ジャッジ日時 2023-08-16 13:58:32
合計ジャッジ時間 6,522 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
56,100 KB
testcase_01 AC 121 ms
55,656 KB
testcase_02 AC 122 ms
55,992 KB
testcase_03 AC 120 ms
53,904 KB
testcase_04 AC 123 ms
56,040 KB
testcase_05 AC 128 ms
55,724 KB
testcase_06 AC 176 ms
56,116 KB
testcase_07 AC 124 ms
56,012 KB
testcase_08 AC 127 ms
55,740 KB
testcase_09 AC 129 ms
55,644 KB
testcase_10 AC 163 ms
56,144 KB
testcase_11 AC 157 ms
55,784 KB
testcase_12 AC 156 ms
56,292 KB
testcase_13 AC 185 ms
56,056 KB
testcase_14 AC 163 ms
56,036 KB
testcase_15 AC 156 ms
56,208 KB
testcase_16 AC 142 ms
55,788 KB
testcase_17 AC 153 ms
56,216 KB
testcase_18 AC 172 ms
56,412 KB
testcase_19 AC 173 ms
55,732 KB
testcase_20 AC 171 ms
56,600 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