結果

問題 No.345 最小チワワ問題
ユーザー Naoyk1212
提出日時 2016-02-26 22:54:46
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 583 bytes
コンパイル時間 2,262 ms
コンパイル使用メモリ 74,592 KB
実行使用メモリ 54,244 KB
最終ジャッジ日時 2024-09-22 22:33:40
合計ジャッジ時間 7,534 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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