結果

問題 No.345 最小チワワ問題
ユーザー yun_appyun_app
提出日時 2016-05-09 13:38:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,027 bytes
コンパイル時間 2,311 ms
コンパイル使用メモリ 74,796 KB
実行使用メモリ 53,356 KB
最終ジャッジ日時 2023-10-26 03:53:59
合計ジャッジ時間 5,355 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
53,324 KB
testcase_01 AC 54 ms
53,332 KB
testcase_02 AC 56 ms
53,328 KB
testcase_03 AC 55 ms
53,336 KB
testcase_04 AC 57 ms
52,304 KB
testcase_05 AC 56 ms
53,332 KB
testcase_06 AC 55 ms
53,336 KB
testcase_07 AC 54 ms
52,244 KB
testcase_08 AC 57 ms
52,320 KB
testcase_09 AC 55 ms
53,332 KB
testcase_10 AC 55 ms
52,264 KB
testcase_11 AC 55 ms
53,332 KB
testcase_12 AC 55 ms
53,336 KB
testcase_13 AC 55 ms
53,332 KB
testcase_14 AC 56 ms
52,304 KB
testcase_15 AC 54 ms
53,340 KB
testcase_16 AC 56 ms
52,292 KB
testcase_17 AC 56 ms
53,328 KB
testcase_18 AC 56 ms
53,336 KB
testcase_19 AC 56 ms
53,340 KB
testcase_20 AC 54 ms
53,336 KB
testcase_21 AC 56 ms
53,340 KB
testcase_22 AC 55 ms
53,332 KB
testcase_23 AC 56 ms
52,252 KB
testcase_24 AC 56 ms
53,336 KB
testcase_25 AC 55 ms
53,336 KB
testcase_26 AC 55 ms
52,264 KB
testcase_27 AC 56 ms
52,280 KB
testcase_28 AC 55 ms
53,348 KB
testcase_29 AC 55 ms
53,324 KB
testcase_30 AC 56 ms
53,332 KB
testcase_31 AC 55 ms
53,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int ans = Integer.MAX_VALUE;
        for(int i=0;i<line.length();i++){
            char c = line.charAt(i);
            if(c == 'c'){
                int wcnt = 0;
                for(int j=i+1;j<line.length();j++){
                    char w = line.charAt(j);
                    if(w == 'w'){
                        wcnt++;
                    }
                    if(wcnt==2){
                        ans = Math.min(ans,j-i+1);
                        break;
                    }
                }
            }
        }
        System.out.println(ans!=Integer.MAX_VALUE?ans:-1);
    }
}
0