結果

問題 No.345 最小チワワ問題
ユーザー Naoyk1212Naoyk1212
提出日時 2016-02-26 22:54:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 4,404 ms
コンパイル使用メモリ 83,128 KB
実行使用メモリ 57,680 KB
最終ジャッジ日時 2023-10-24 05:42:58
合計ジャッジ時間 8,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
57,512 KB
testcase_01 AC 121 ms
57,452 KB
testcase_02 AC 121 ms
57,652 KB
testcase_03 AC 122 ms
57,508 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 135 ms
57,680 KB
testcase_08 AC 120 ms
57,504 KB
testcase_09 AC 122 ms
57,560 KB
testcase_10 AC 125 ms
57,516 KB
testcase_11 AC 125 ms
57,452 KB
testcase_12 AC 121 ms
57,476 KB
testcase_13 AC 122 ms
57,312 KB
testcase_14 WA -
testcase_15 AC 121 ms
57,176 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 122 ms
57,472 KB
testcase_20 AC 122 ms
57,536 KB
testcase_21 AC 120 ms
57,560 KB
testcase_22 AC 122 ms
57,400 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 122 ms
57,348 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 121 ms
57,532 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