結果

問題 No.467 隠されていたゲーム
ユーザー sima.tetteke
提出日時 2019-10-26 22:23:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 377 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 1,806 ms
コンパイル使用メモリ 165,940 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 19:16:37
合計ジャッジ時間 2,578 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919;
ll N, M;

int main(){

    ll n; cin >> n;
    set<ll > d;
    for(ll i = 0; i < n; i++){
        ll t; cin >> t; d.insert(t);
    }
    ll x, y; cin >> x >> y;
    ll goal = max(abs(x), abs(y));
    if(goal == 0){
        cout << 0 << endl;
        return 0;
    }
    if(d.find(goal) != d.end()){
        cout << 1 << endl;
        return 0;
    }

    //setの最大値
    auto it = d.end(); it--;
    ll mx_d = *it;
    //cout << mx_d << endl;

    ll ans = 0;
    while(goal >= 2 * mx_d){
        goal -= mx_d;
        ans++;
    }
    if(goal == mx_d){
        ans++;
    }else{
        ans+=2;
    }
    cout << ans << endl;

}
0