結果
問題 |
No.467 隠されていたゲーム
|
ユーザー |
|
提出日時 | 2017-01-14 16:23:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,069 bytes |
コンパイル時間 | 656 ms |
コンパイル使用メモリ | 76,100 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 16:25:50 |
合計ジャッジ時間 | 1,567 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#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; }