結果
問題 | No.334 門松ゲーム |
ユーザー | Daigo HIROOKA |
提出日時 | 2018-05-26 01:44:42 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 201 ms / 2,000 ms |
コード長 | 960 bytes |
コンパイル時間 | 4,643 ms |
コンパイル使用メモリ | 79,024 KB |
実行使用メモリ | 57,840 KB |
最終ジャッジ日時 | 2023-09-11 03:34:20 |
合計ジャッジ時間 | 8,421 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 167 ms
56,716 KB |
testcase_01 | AC | 127 ms
55,812 KB |
testcase_02 | AC | 157 ms
56,136 KB |
testcase_03 | AC | 169 ms
56,808 KB |
testcase_04 | AC | 172 ms
56,928 KB |
testcase_05 | AC | 166 ms
56,508 KB |
testcase_06 | AC | 200 ms
57,452 KB |
testcase_07 | AC | 157 ms
56,380 KB |
testcase_08 | AC | 190 ms
55,720 KB |
testcase_09 | AC | 157 ms
56,072 KB |
testcase_10 | AC | 180 ms
56,104 KB |
testcase_11 | AC | 193 ms
57,696 KB |
testcase_12 | AC | 192 ms
57,276 KB |
testcase_13 | AC | 190 ms
57,840 KB |
testcase_14 | AC | 161 ms
55,972 KB |
testcase_15 | AC | 201 ms
57,132 KB |
ソースコード
import java.util.*; public class No334{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); StringBuilder sb = new StringBuilder(); int[] K = new int[N]; for(int i = 0; i < N; i++){ K[i] = sc.nextInt(); } if(game(K)) System.out.println(ans[0]+" "+ans[1]+" "+ans[2]); else System.out.println(-1); } static int[] ans = new int[3]; private static boolean game(int[] K){ int n = K.length; for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ for(int k = j+1; k < n; k++){ int a = K[i]; int b = K[j]; int c = K[k]; if(a == -1 || b == -1 || c == -1) continue; if(b > Math.max(a, c) || b < Math.min(a, c)){ int[] d = Arrays.copyOf(K, K.length); d[i] = d[j] = d[k] = -1; if(!game(d)){ ans[0] = i; ans[1] = j; ans[2] = k; return true; // D wins } } } } } return false; // D lose } }