結果

問題 No.602 隠されていたゲーム2
ユーザー たこしたこし
提出日時 2017-12-02 09:17:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 1,060 ms
コンパイル使用メモリ 150,404 KB
実行使用メモリ 13,768 KB
最終ジャッジ日時 2023-08-18 19:55:03
合計ジャッジ時間 2,804 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 15 ms
4,788 KB
testcase_17 AC 37 ms
6,512 KB
testcase_18 AC 82 ms
11,600 KB
testcase_19 AC 144 ms
13,476 KB
testcase_20 AC 101 ms
13,476 KB
testcase_21 AC 115 ms
13,516 KB
testcase_22 WA -
testcase_23 AC 99 ms
13,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define int long long
//using LL = long long int;
using II = pair<int, int>;

const int MAX_N = 100005;

int N;
int D[MAX_N];
int X, Y;

signed main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> D[i];
  }
  cin >> X >> Y;

  int XYD = abs(X) + abs(Y);

  if(X == 0 && Y == 0) {
    cout << 0 << endl;
    return 0;
  }

  set<int> S;
  for(int i = 0; i < N; i++) {
    if(XYD == D[i]) {
      cout << 1 << endl;
      return 0;
    }
    S.insert(D[i]);
    S.insert(-D[i]);
  }

  for(int i = 0; i < N; i++) {
    if(S.find(XYD - D[i]) != S.end() || S.find(D[i] - XYD) != S.end()) {
      cout << 2 << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}
0