結果

問題 No.345 最小チワワ問題
ユーザー Naoyk1212Naoyk1212
提出日時 2016-02-26 23:02:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 2,443 ms
コンパイル使用メモリ 75,388 KB
実行使用メモリ 57,692 KB
最終ジャッジ日時 2023-10-24 05:49:47
合計ジャッジ時間 7,881 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,420 KB
testcase_01 AC 131 ms
57,636 KB
testcase_02 AC 131 ms
57,424 KB
testcase_03 AC 131 ms
57,464 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 131 ms
57,456 KB
testcase_08 AC 128 ms
57,444 KB
testcase_09 AC 129 ms
57,552 KB
testcase_10 AC 127 ms
57,408 KB
testcase_11 AC 128 ms
57,468 KB
testcase_12 AC 129 ms
57,568 KB
testcase_13 AC 128 ms
57,364 KB
testcase_14 WA -
testcase_15 AC 131 ms
57,476 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 129 ms
55,560 KB
testcase_20 AC 127 ms
57,508 KB
testcase_21 AC 128 ms
57,476 KB
testcase_22 AC 131 ms
57,504 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 127 ms
57,484 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 126 ms
57,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char c1 = 'c';
		char c2 = 'w';
		int count = 0;
		int ans = -1;

		int i = 0;
		while(i < str.length()){
			if(str.charAt(i) == c1){
				int a = i;
				while(i < str.length()){
					if(str.charAt(i) == c2){
						count++;
						if(count == 2){
							ans = i + 1 - a;
							break;
						}
					}
					i++;
				}
				break;
			}
			i++;
		}
		System.out.println(ans);
	}
}
0