結果
問題 | No.334 門松ゲーム |
ユーザー | Daigo HIROOKA |
提出日時 | 2018-05-26 02:07:27 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 172 ms / 2,000 ms |
コード長 | 1,028 bytes |
コンパイル時間 | 4,004 ms |
コンパイル使用メモリ | 76,756 KB |
実行使用メモリ | 57,172 KB |
最終ジャッジ日時 | 2023-09-11 03:34:44 |
合計ジャッジ時間 | 7,660 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 169 ms
57,064 KB |
testcase_01 | AC | 125 ms
55,736 KB |
testcase_02 | AC | 143 ms
56,212 KB |
testcase_03 | AC | 168 ms
56,536 KB |
testcase_04 | AC | 170 ms
56,648 KB |
testcase_05 | AC | 167 ms
56,852 KB |
testcase_06 | AC | 172 ms
56,844 KB |
testcase_07 | AC | 145 ms
56,012 KB |
testcase_08 | AC | 167 ms
56,864 KB |
testcase_09 | AC | 131 ms
55,984 KB |
testcase_10 | AC | 143 ms
56,332 KB |
testcase_11 | AC | 170 ms
56,968 KB |
testcase_12 | AC | 169 ms
56,684 KB |
testcase_13 | AC | 166 ms
57,016 KB |
testcase_14 | AC | 130 ms
55,976 KB |
testcase_15 | AC | 171 ms
57,172 KB |
ソースコード
import java.util.*; public class No334_2{ 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(b > Math.max(a, c) || b < Math.min(a, c)){ int[] K_new = new int[n-3]; int idx = 0; for(int l = 0; l < n; l++){ if(l == i || l == j || l == k) continue; K_new[idx] = K[l]; idx++; } if(!game(K_new)){ ans[0] = i; ans[1] = j; ans[2] = k; return true; // D wins } } } } } return false; // D lose } }