結果
| 問題 |
No.467 隠されていたゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-04 14:20:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 796 bytes |
| コンパイル時間 | 822 ms |
| コンパイル使用メモリ | 76,236 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-13 09:33:54 |
| 合計ジャッジ時間 | 1,878 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 6 |
ソースコード
#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(x, y);
int ans = 0, pos = 0;
if(abs(y) > 2*d[n-1]){
ans = (abs(y) - 4*d[n-1]) / d[n-1];
if(y-pos > 0) pos = ans * d[n-1];
if(y-pos < 0) pos = -pos;
}
while(abs(y-pos) > 2*d[n-1]){
ans++;
if(y-pos > 0) pos += d[n-1];
else 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;
}