結果

問題 No.334 門松ゲーム
ユーザー YamaKasaYamaKasa
提出日時 2018-09-15 15:39:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,116 bytes
コンパイル時間 3,450 ms
コンパイル使用メモリ 76,016 KB
実行使用メモリ 67,708 KB
最終ジャッジ日時 2023-09-25 06:29:38
合計ジャッジ時間 6,730 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 158 ms
57,148 KB
testcase_04 AC 158 ms
56,928 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[]K = new int[N];
		for(int i = 0; i < N; i++) {
			K[i] = scan.nextInt();
		}
		scan.close();

		if(!game(K)) {
			System.out.println(-1);
		}
	}
	static boolean game(int[] K) {
		int n = K.length;
//		if(n < 3) {
//			return false;
//		}
		for(int i = 0; i < n - 2; i++) {
			for(int j = i + 1; j < n - 1; j++) {
				for(int k = j + 1; k < n; k++) {
					int a = K[i];
					int b = K[j];
					int c = K[k];
					if(isCheck(a, b, c)) {
						int[] K1 = new int[n - 3];
						int idx = 0;
						// 残りの数列を作成する
						for(int l = 0; l < n; l++) {
							if(l == i || l == j || l == k) {
								continue;
							}
							K1[idx] = K[l];
							idx++;
						}
						if(!game(K1)) {
							System.out.println(i + " " + j + " " + k);
							return true;
						}
					}
				}
			}
		}
		return false;

	}
	static boolean isCheck(int a, int b, int c) {
		if(b > Math.min(a, c) || b < Math.min(a, c)) {
			return true;
		}
		return false;
	}

}
0