結果

問題 No.345 最小チワワ問題
ユーザー yuikibis
提出日時 2016-02-28 21:40:57
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 74,312 KB
実行使用メモリ 56,628 KB
最終ジャッジ日時 2024-09-24 12:11:08
合計ジャッジ時間 7,732 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String text = scanner.next();

        int length = - 1;
        boolean c = false;
        boolean w1 = false;
        int start = 0;
        for (int i = 0; i < text.length(); i++) {
            if (text.charAt(i) == 'c') {
                start = i;
                c = true;
            } else if (text.charAt(i) == 'w' && c) {
                if (!w1) {
                    w1 = true;
                } else {
                    int tmpLength = i - start + 1;
                    if (length < tmpLength) {
                        length = tmpLength;
                    }
                    start = 0;
                    c = w1 = false;
                }
            }
        }
        System.out.println(length);
    }
}
0