結果

問題 No.345 最小チワワ問題
ユーザー 37zigen37zigen
提出日時 2016-03-11 01:46:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 4,049 ms
コンパイル使用メモリ 78,908 KB
実行使用メモリ 57,760 KB
最終ジャッジ日時 2023-10-26 03:45:50
合計ジャッジ時間 9,758 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
57,616 KB
testcase_01 AC 131 ms
57,584 KB
testcase_02 AC 129 ms
57,756 KB
testcase_03 AC 131 ms
55,552 KB
testcase_04 AC 135 ms
57,548 KB
testcase_05 AC 135 ms
57,436 KB
testcase_06 AC 135 ms
57,760 KB
testcase_07 AC 134 ms
57,504 KB
testcase_08 AC 138 ms
57,364 KB
testcase_09 AC 132 ms
57,648 KB
testcase_10 AC 134 ms
57,696 KB
testcase_11 AC 132 ms
57,504 KB
testcase_12 AC 146 ms
57,712 KB
testcase_13 AC 148 ms
57,472 KB
testcase_14 AC 143 ms
57,748 KB
testcase_15 AC 137 ms
57,684 KB
testcase_16 AC 135 ms
57,520 KB
testcase_17 AC 136 ms
55,264 KB
testcase_18 AC 138 ms
57,272 KB
testcase_19 AC 134 ms
57,632 KB
testcase_20 AC 131 ms
57,480 KB
testcase_21 AC 129 ms
57,512 KB
testcase_22 AC 139 ms
57,224 KB
testcase_23 AC 137 ms
57,704 KB
testcase_24 AC 134 ms
57,524 KB
testcase_25 AC 134 ms
57,504 KB
testcase_26 AC 129 ms
57,476 KB
testcase_27 AC 134 ms
57,592 KB
testcase_28 AC 133 ms
57,480 KB
testcase_29 AC 135 ms
57,476 KB
testcase_30 AC 136 ms
57,188 KB
testcase_31 AC 134 ms
57,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String str=sc.next();
		int ans=Integer.MAX_VALUE;
		for(int i=0;i<str.length();i++){
			for(int j=i+1;j<str.length();j++){
				for(int k=j+1;k<str.length();k++){
					if(str.charAt(i)=='c'&&str.charAt(j)=='w'&&str.charAt(k)=='w'){
						ans=Math.min(ans,k-i+1);
					}
				}
			}
		}
		if(ans==Integer.MAX_VALUE)
			ans=-1;
		System.out.println(ans);
	}
}
0