結果

問題 No.345 最小チワワ問題
ユーザー mizunomi32mizunomi32
提出日時 2016-02-28 22:10:01
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 769 bytes
コンパイル時間 3,386 ms
コンパイル使用メモリ 74,932 KB
実行使用メモリ 57,632 KB
最終ジャッジ日時 2023-10-24 18:53:10
合計ジャッジ時間 8,436 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 124 ms
57,288 KB
testcase_08 AC 127 ms
57,412 KB
testcase_09 AC 124 ms
57,376 KB
testcase_10 WA -
testcase_11 AC 124 ms
57,372 KB
testcase_12 AC 125 ms
57,384 KB
testcase_13 AC 129 ms
57,420 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 123 ms
57,552 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 124 ms
57,224 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 125 ms
57,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] chars = s.toCharArray();
        int charlonger = s.length();
        int i=0;
        int flag =0;
        int a=0,b=-1;
        int con=1;


        for(;i<charlonger;i++){
            if(chars[i] == 'c'){
                flag = 1;
                a=i;
            }else if(flag == 1 && chars[i] == 'w'){
                  flag = 2;

            }else if(flag == 2 && chars[i] == 'w' ){
                con ++;
                flag=0;
                if(i-a+1 <b || con==-1){
                    b= i-a+1;
                }

            }
        }
            System.out.println(b);
    }
}
0