結果
問題 |
No.467 隠されていたゲーム
|
ユーザー |
|
提出日時 | 2018-09-04 14:21:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 644 ms |
コンパイル使用メモリ | 75,468 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 09:37:51 |
合計ジャッジ時間 | 1,473 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> using namespace std; int main(){ int n; cin >> n; vector<int> d(n); for(int i = 0; i < n; i++) cin >> d[i]; sort(d.begin(), d.end()); int x, y; cin >> x >> y; y = max(abs(x), abs(y)); int ans = 0, pos = 0; if(abs(y) > 2*d[n-1]){ ans = (abs(y) - 4*d[n-1]) / d[n-1]; pos = ans * d[n-1]; } while(abs(y-pos) > 2*d[n-1]){ ans++; pos += d[n-1]; } if(abs(y-pos) != 0){ if(*lower_bound(d.begin(), d.end(), abs(y-pos)) == abs(y-pos)){ ans++; }else{ ans += 2; } } cout << ans << endl; return 0; }