結果
問題 | No.345 最小チワワ問題 |
ユーザー | mizunomi32 |
提出日時 | 2016-02-28 21:15:23 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 754 bytes |
コンパイル時間 | 3,283 ms |
コンパイル使用メモリ | 79,040 KB |
実行使用メモリ | 57,528 KB |
最終ジャッジ日時 | 2023-10-24 18:48:10 |
合計ジャッジ時間 | 7,815 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 103 ms
55,932 KB |
testcase_01 | AC | 103 ms
56,192 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 114 ms
57,300 KB |
testcase_06 | AC | 104 ms
56,108 KB |
testcase_07 | AC | 103 ms
56,248 KB |
testcase_08 | AC | 115 ms
57,384 KB |
testcase_09 | AC | 113 ms
57,528 KB |
testcase_10 | AC | 103 ms
56,200 KB |
testcase_11 | AC | 111 ms
57,268 KB |
testcase_12 | AC | 114 ms
57,328 KB |
testcase_13 | AC | 114 ms
57,232 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 120 ms
57,508 KB |
testcase_21 | AC | 117 ms
57,432 KB |
testcase_22 | AC | 113 ms
57,244 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 119 ms
57,112 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 122 ms
55,356 KB |
ソースコード
import java.util.Scanner; 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=0; 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' ){ flag =3; b=i; } } if(flag == 3){ System.out.println(b-a+1); }else{ System.out.println("-1"); } } }