結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2017-12-02 00:47:38 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,243 bytes |
| コンパイル時間 | 2,524 ms |
| コンパイル使用メモリ | 79,456 KB |
| 実行使用メモリ | 59,092 KB |
| 最終ジャッジ日時 | 2024-11-28 01:57:34 |
| 合計ジャッジ時間 | 9,220 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 8 WA * 13 |
ソースコード
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeSet;
public class Main {
public static long MOD = 1000000007;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final int n = sc.nextInt();
TreeSet<Long> set = new TreeSet<Long>();
for(int i = 0; i < n; i++){ set.add(sc.nextLong()); }
ArrayList<Long> arr = new ArrayList<>(set);
final long x = sc.nextLong();
final long y = sc.nextLong();
final long d = Math.abs(x) + Math.abs(y);
if(d == 0){
System.out.println(0);
return;
}
for(final long s : arr){
if(d == s){
System.out.println(1);
return;
}
}
/*
for(int i = 0; i < arr.size(); i++){
final long s = arr.get(i);
{ // d = s1 + s2
final long rest = Math.abs(d - s);
final int pos = Collections.binarySearch(arr, rest);
if(pos >= 0){
System.out.println(2);
return;
}
}
{ // d = s1 - s2
final long rest = Math.abs(s - d);
final int pos = Collections.binarySearch(arr, rest);
if(pos >= 0){
System.out.println(2);
return;
}
}
}
*/
System.out.println(-1);
}
}
uafr_cs