結果

問題 No.345 最小チワワ問題
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 16:01:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 2,542 ms
コンパイル使用メモリ 74,380 KB
実行使用メモリ 57,652 KB
最終ジャッジ日時 2023-10-26 04:24:36
合計ジャッジ時間 7,861 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,568 KB
testcase_01 AC 131 ms
57,232 KB
testcase_02 AC 130 ms
57,232 KB
testcase_03 AC 133 ms
57,236 KB
testcase_04 AC 130 ms
57,412 KB
testcase_05 AC 129 ms
57,132 KB
testcase_06 AC 128 ms
57,212 KB
testcase_07 AC 129 ms
57,416 KB
testcase_08 AC 126 ms
57,484 KB
testcase_09 AC 130 ms
57,416 KB
testcase_10 AC 129 ms
57,556 KB
testcase_11 AC 131 ms
57,480 KB
testcase_12 AC 129 ms
57,252 KB
testcase_13 AC 132 ms
57,252 KB
testcase_14 AC 130 ms
57,184 KB
testcase_15 AC 132 ms
57,468 KB
testcase_16 AC 129 ms
57,504 KB
testcase_17 AC 135 ms
57,540 KB
testcase_18 AC 127 ms
57,168 KB
testcase_19 AC 127 ms
57,468 KB
testcase_20 AC 118 ms
56,336 KB
testcase_21 AC 127 ms
57,580 KB
testcase_22 AC 127 ms
57,188 KB
testcase_23 AC 128 ms
57,168 KB
testcase_24 AC 134 ms
57,272 KB
testcase_25 AC 132 ms
57,224 KB
testcase_26 AC 132 ms
57,244 KB
testcase_27 AC 131 ms
57,260 KB
testcase_28 AC 131 ms
57,600 KB
testcase_29 AC 132 ms
57,472 KB
testcase_30 AC 133 ms
57,552 KB
testcase_31 AC 131 ms
57,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		String status = "";
		int min = 1000;
		int len = 0;
		int j = 0;
		for (int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			if (c!='c') {continue;}
			
			int t = 0;
			for (j=i+1; j<s.length(); j++) {
				if (s.charAt(j)=='w') {t++;}
				if (t == 2) {break;}
			}
			if (t == 2) {
				j = j-i+1;
				min = Math.min(min,j);
			}
		}
		System.out.println(min==1000?-1:min);
	}
}
0