結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-02 02:58:49 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 919 bytes |
| コンパイル時間 | 2,278 ms |
| コンパイル使用メモリ | 79,072 KB |
| 実行使用メモリ | 59,892 KB |
| 最終ジャッジ日時 | 2024-11-28 02:31:25 |
| 合計ジャッジ時間 | 9,505 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 7 |
ソースコード
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
long[] d = new long[n];
for (int i = 0; i < n; ++i) {
d[i] = sc.nextLong();
}
int x = sc.nextInt();
int y = sc.nextInt();
x = Math.abs(x);
y = Math.abs(y);
if (x == 0 && y == 0) {
System.out.println(0);
return;
}
for (int i = 0; i < n; ++i) {
if (d[i] == x + y) {
System.out.println(1);
return;
}
}
HashSet<Long> set = new HashSet();
for (int i = 0; i < n; ++i) {
set.add(d[i]);
}
for (int i = 0; i < n; ++i) {
if (!set.contains(x + y - d[i]) && !set.contains(x + y + d[i]))
continue;
System.out.println(2);
return;
}
System.out.println(-1);
}
static void tr(Object... objects) {
System.out.println(Arrays.deepToString(objects));
}
}