結果
問題 | No.345 最小チワワ問題 |
ユーザー | mizunomi32 |
提出日時 | 2016-02-28 22:05:56 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 819 bytes |
コンパイル時間 | 3,717 ms |
コンパイル使用メモリ | 78,952 KB |
実行使用メモリ | 57,652 KB |
最終ジャッジ日時 | 2023-10-24 18:52:24 |
合計ジャッジ時間 | 9,143 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 113 ms
55,196 KB |
testcase_01 | AC | 113 ms
57,512 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 115 ms
57,448 KB |
testcase_05 | AC | 106 ms
56,868 KB |
testcase_06 | AC | 103 ms
55,972 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 113 ms
56,992 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 113 ms
57,140 KB |
testcase_15 | AC | 114 ms
57,160 KB |
testcase_16 | AC | 115 ms
57,300 KB |
testcase_17 | WA | - |
testcase_18 | AC | 115 ms
57,468 KB |
testcase_19 | AC | 106 ms
56,432 KB |
testcase_20 | AC | 115 ms
56,996 KB |
testcase_21 | WA | - |
testcase_22 | AC | 113 ms
57,332 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 104 ms
55,036 KB |
testcase_30 | AC | 103 ms
56,252 KB |
testcase_31 | WA | - |
ソースコード
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=9999; 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 ++; if(i-a+1 <b){ b= i-a+1; } } } if(con >0){ System.out.println(b); }else{ System.out.println("-1"); } } }