結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー |
![]() |
提出日時 | 2015-02-14 12:36:35 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 267 ms / 5,000 ms |
コード長 | 998 bytes |
コンパイル時間 | 3,681 ms |
コンパイル使用メモリ | 77,884 KB |
実行使用メモリ | 47,704 KB |
最終ジャッジ日時 | 2024-10-11 01:53:03 |
合計ジャッジ時間 | 8,428 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
import java.util.Scanner; public class GO { /** * @param args */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); String s=null; String good ="good",problem="problem"; for (int t = 0; t < T; t++) { int ans = 1<<29; s = sc.next(); for (int i = 0; i < s.length(); i++) { for (int j = i+good.length(); j <= s.length()-problem.length(); j++) { int sum = 0; sum = len(good,s.substring(i,i+good.length())) + len(problem,s.substring(j,j+problem.length())); ans = Math.min(ans, sum); } } System.out.println(ans); } } static int len(String s,String t){ int res = 0; for (int i = 0; i < s.length(); i++) { res += s.charAt(i)==t.charAt(i)?0:1; } return res; } }