結果

問題 No.345 最小チワワ問題
ユーザー Naoyk1212Naoyk1212
提出日時 2016-02-27 00:10:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 77,760 KB
実行使用メモリ 57,652 KB
最終ジャッジ日時 2023-10-24 18:00:47
合計ジャッジ時間 7,057 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
57,572 KB
testcase_01 AC 123 ms
57,476 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 122 ms
57,260 KB
testcase_05 WA -
testcase_06 AC 124 ms
57,428 KB
testcase_07 AC 130 ms
57,612 KB
testcase_08 AC 124 ms
57,384 KB
testcase_09 AC 124 ms
57,268 KB
testcase_10 AC 124 ms
57,308 KB
testcase_11 AC 125 ms
57,348 KB
testcase_12 AC 125 ms
57,552 KB
testcase_13 AC 124 ms
57,488 KB
testcase_14 AC 125 ms
57,404 KB
testcase_15 AC 121 ms
57,084 KB
testcase_16 AC 126 ms
57,548 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 121 ms
57,152 KB
testcase_20 AC 133 ms
57,448 KB
testcase_21 AC 132 ms
57,600 KB
testcase_22 AC 122 ms
57,652 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 124 ms
57,372 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 125 ms
57,648 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) == c1){
						a = i;
					}
					if(str.charAt(i) == c2){
						count++;
						if(count == 2){
							ans = i + 1 - a;
							break;
						}
					}
					i++;
				}
				break;
			}
			i++;
		}
		System.out.println(ans);
	}
}
0