結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 9 ms
4,380 KB
testcase_17 WA -
testcase_18 AC 57 ms
7,440 KB
testcase_19 WA -
testcase_20 AC 49 ms
8,756 KB
testcase_21 AC 61 ms
8,556 KB
testcase_22 WA -
testcase_23 AC 72 ms
8,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using LL = long long int;
using II = pair<int, int>;

const int MAX_N = 100005;

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

int 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(XYD - D[i]) != S.end()) {
      cout << 2 << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}
0