結果

問題 No.467 隠されていたゲーム
コンテスト
ユーザー zengyongxu-jerry
提出日時 2026-06-21 21:27:09
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,436 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,145 ms
コンパイル使用メモリ 331,192 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-21 21:27:14
合計ジャッジ時間 3,372 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define piii pair<pii, int>
#define pll pair<ll, ll>
#define plll pair<pll, ll>
#define fi first
#define se second
const int N = 2e5 + 5, M = 1e6 + 5;
const int inf = 1e9, mod = 998244353;
const ll INF = 1e18;

namespace ARIS0_0{
	int n, d[N], x, y;
	
	void init(){
	}
	int get(int a, int b){
		assert(a <= 2 * b);
		if (a % b == 0) return a / b;
		return 2;
	}
	void solve(){
		int n; cin >> n;
		for (int i = 1; i <= n; i ++ ) cin >> d[i];
		cin >> x >> y;
		
		int mxd = 0;
		for (int i = 1; i <= n; i ++ ) mxd = max(mxd, d[i]);
		
		if (x < 0) x = -x;
		if (y < 0) y = -y;
		if (x == 0 && y == 0){
			cout << "0\n";
			return ;
		}
		
		int qwq = max(x, y);
		for (int i = 1; i <= n; i ++)
			if (qwq == d[i]){
				cout << "1\n";
				return ;
			}
		if (qwq < 2 * mxd){
			cout << get(qwq, mxd) << "\n";
			return ;
		}
		
		int fir = (qwq - 2 * mxd);
		int x = (fir - 1) / mxd + 1;
		cout << x + get(qwq - x * mxd, mxd) << "\n";
	}
	void single(){ init(), solve(); }
	void multi(){ init(); int T; cin >> T; while (T -- ) solve(); }
	void idmulti(){ init(); int id, T; cin >> id >> T; while (T -- ) solve(); }
};

signed main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ARIS0_0::single();
}
 
/*

到达 (x, y) (x <= 2d, y <= 2d) 可以通过
(0, 0) -> (x - d, d) -> (x, y) 走到
然后咋搞,感觉有很多细节啊 

*/
0