結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 10 ms
4,376 KB
testcase_17 AC 24 ms
5,216 KB
testcase_18 AC 54 ms
7,988 KB
testcase_19 AC 81 ms
9,016 KB
testcase_20 AC 57 ms
8,840 KB
testcase_21 AC 63 ms
8,856 KB
testcase_22 WA -
testcase_23 AC 73 ms
9,012 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]);
  }

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

  cout << -1 << endl;

  return 0;
}
0