結果

問題 No.467 隠されていたゲーム
ユーザー tak0kadatak0kada
提出日時 2017-01-14 16:23:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,069 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 76,300 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 04:46:17
合計ジャッジ時間 1,290 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

template <class T>
std::ostream& operator<< (std::ostream& stream, const std::vector<T>& vec)
{
    stream << "[ ";
    for (const auto &i: vec) stream << i << " ";
    stream << "]";
    return stream;
}

int solve()
{
    using namespace std;
    
    // input
    int n_input;
    cin >> n_input;
    vector<int> d(n_input);
    for (int i = 0; i < n_input; ++i)
    {
        cin >> d[i];
    }
    int goal_x, goal_y;
    cin >> goal_x >> goal_y;
    int goal = max(abs(goal_x), abs(goal_y));
    
    // algorithm
    int max_d = *max_element(d.begin(), d.end());
    if (goal == 0)
        return 0;
    else
    {
        if (max_d == 0)
            return -1;
        if (goal >= max_d)
            return (goal / max_d) + (goal % max_d == 0 ? 0 : 1);
        else
        {
            for (const auto& i: d)
                if (i == goal)
                    return 1;
            return 2;
        }
    }
}

int main(void)
{
    std::cout << solve() << std::endl;
    return 0;
}
0