結果
問題 |
No.334 門松ゲーム
|
ユーザー |
|
提出日時 | 2018-05-26 02:07:27 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 1,028 bytes |
コンパイル時間 | 3,829 ms |
コンパイル使用メモリ | 82,372 KB |
実行使用メモリ | 42,644 KB |
最終ジャッジ日時 | 2024-06-28 18:07:56 |
合計ジャッジ時間 | 6,577 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
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 } }