結果

問題 No.467 隠されていたゲーム
ユーザー tak0kadatak0kada
提出日時 2017-01-14 16:17:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 76,024 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 10:36:25
合計ジャッジ時間 1,953 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 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 2;
        else
            return (goal / max_d) + (goal % max_d == 0 ? 0 : 1);
    }
}

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