結果
問題 | No.345 最小チワワ問題 |
ユーザー | TwinkleStar74 |
提出日時 | 2017-09-19 00:12:07 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 835 bytes |
コンパイル時間 | 1,926 ms |
コンパイル使用メモリ | 75,164 KB |
実行使用メモリ | 50,524 KB |
最終ジャッジ日時 | 2024-04-25 15:35:26 |
合計ジャッジ時間 | 4,611 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
50,352 KB |
testcase_01 | WA | - |
testcase_02 | AC | 52 ms
50,064 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 51 ms
50,328 KB |
testcase_08 | AC | 52 ms
50,420 KB |
testcase_09 | AC | 52 ms
50,232 KB |
testcase_10 | AC | 52 ms
49,920 KB |
testcase_11 | AC | 51 ms
50,320 KB |
testcase_12 | AC | 52 ms
50,196 KB |
testcase_13 | AC | 51 ms
50,256 KB |
testcase_14 | WA | - |
testcase_15 | AC | 53 ms
50,364 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 53 ms
50,380 KB |
testcase_20 | AC | 54 ms
50,420 KB |
testcase_21 | AC | 52 ms
49,912 KB |
testcase_22 | AC | 54 ms
50,304 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 52 ms
50,316 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 52 ms
50,312 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; class No345 { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int C =str.indexOf("c"); //cの位置 int W1 = str.indexOf("w"); //1つ目のwの位置 int W2 = str.indexOf("w",W1+1); //2つ目のwの位置 if (C !=-1 && W1 !=-1 && W2 != -1 && //cww全てが含まれ、且つCが一番小さい時 C == Calc.min(C, W1,W2)){ System.out.println( (W2 - C) + 1 ); } else System.out.println(-1); } public static class Calc { //3つの数字の中で最小の物を返すメソッド(xだけ) public static int min(int x, int y, int z){ if (x < y && x < z) return x; else return 0; } } }