結果

問題 No.467 隠されていたゲーム
ユーザー ferinferin
提出日時 2017-01-25 18:45:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 1,336 ms
コンパイル使用メモリ 160,236 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 04:46:38
合計ジャッジ時間 1,776 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void)
{
  int n;
  cin >> n;
  ll d[20], maxd = -1*INF*2;
  REP(i, n) {
    cin >> d[i];
    maxd = max(maxd, d[i]);
  }
  ll x, y;
  cin >> x >> y;
  x = abs(x); y = abs(y);

  if(x == 0 && y == 0) {cout << 0 << endl; return 0;}
  //最初から2d以下
  if(max(x, y) <= maxd * 2) {
    //1手で移動できるのが存在するか
    REP(i, n) {
      if(d[i] == max(x, y)) {cout << 1 << endl; return 0;}
    }
    //存在しなければ2手
    cout << 2 << endl;
    return 0;
  } else {
    //2d未満になるまで近づく
    ll step = (max(x, y)-maxd)/maxd;
    ll pos = step*maxd;
    //そこから1手でたどり着けるか
    REP(i, n) {
      if(d[i] == max(x, y)-pos) {
        cout << step+1 << endl;
        return 0;
      }
    }
    cout << step+2 << endl;
  }

  return 0;
}
0