結果
問題 | No.467 隠されていたゲーム |
ユーザー | shinwisteria |
提出日時 | 2017-03-24 18:15:30 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,057 bytes |
コンパイル時間 | 5,763 ms |
コンパイル使用メモリ | 76,628 KB |
実行使用メモリ | 56,152 KB |
最終ジャッジ日時 | 2023-09-20 06:04:22 |
合計ジャッジ時間 | 13,171 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 130 ms
55,924 KB |
testcase_01 | AC | 128 ms
56,152 KB |
testcase_02 | AC | 130 ms
55,876 KB |
testcase_03 | AC | 126 ms
56,048 KB |
testcase_04 | WA | - |
testcase_05 | AC | 128 ms
55,864 KB |
testcase_06 | WA | - |
testcase_07 | AC | 129 ms
55,812 KB |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
import java.util.ArrayDeque; import java.util.Arrays; import java.util.Queue; import java.util.Scanner; import java.util.TreeSet; public class HiddenGame { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); int[] d = new int[N]; for(int i = 0;i < N;i++){ d[i] = s.nextInt(); } Arrays.sort(d); int goalx = s.nextInt(),goaly = s.nextInt(); s.close(); int goal = Integer.max(Math.abs(goalx), Math.abs(goaly)); int count = 2; TreeSet<Integer> T1 = new TreeSet<>(); TreeSet<Integer> T2 = new TreeSet<>(); Queue<Integer> REST = new ArrayDeque<>(); REST.add(goal); for(;;){ int rest = REST.poll(); T1.clear(); for(int i : d){ T1.add(Math.abs(rest-i)); } for(int i:T1){ for(int j:d){ T2.add(Math.abs(i-j)); } } if(T2.contains(0)){ break; }else if(T1.first() == T2.first()){ count = -1; } REST.clear(); REST.addAll(T1); T1 = new TreeSet<Integer>(T2); T2.clear(); count++; } System.out.println(count); } }