結果

問題 No.602 隠されていたゲーム2
ユーザー ei1333333ei1333333
提出日時 2017-12-02 00:42:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 205,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 00:24:50
合計ジャッジ時間 3,472 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 9 ms
5,376 KB
testcase_17 AC 16 ms
5,376 KB
testcase_18 AC 41 ms
5,376 KB
testcase_19 AC 50 ms
5,336 KB
testcase_20 AC 47 ms
5,376 KB
testcase_21 AC 34 ms
5,376 KB
testcase_22 AC 50 ms
5,376 KB
testcase_23 AC 46 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main()
{
  int N, D[100000], X, Y;

  cin >> N;

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

  cin >> X >> Y;

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

  int F = abs(X) + abs(Y);
  for(int i = 0; i < N; i++) {
    if(F == D[i]) {
      cout << 1 << endl;
      return (0);
    }
  }

  sort(D, D + N);
  vector< int > push;
  int S = X + Y, T = X - Y;
  for(int i = 0; i < N; i++) {
    push.emplace_back(max({D[i] - S, -D[i] + T, D[i] - T, -D[i] + T}));
  }
  for(int i = 0; i < push.size(); i++) {
    if(binary_search(D, D + N, push[i])) {
      cout << 2 << endl;
      return (0);
    }
  }
  cout << -1 << endl;
}
0