結果

問題 No.602 隠されていたゲーム2
ユーザー pekempey
提出日時 2017-12-02 00:18:33
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 71,416 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-28 01:24:14
合計ジャッジ時間 1,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;

  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }

  int x, y;
  cin >> x >> y;

  if (x == 0 && y == 0) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < n; i++) {
    if (abs(x) + abs(y) == d[i]) {
      cout << 1 << endl;
      return 0;
    }
  }

  for (int i = 0; i < n; i++) {
    if (abs(x) + abs(y) <= 2 * d[i]) {
      cout << 2 << endl;
      return 0;
    }
  }

  cout << -1 << endl;
}
0