結果
問題 | No.467 隠されていたゲーム |
ユーザー |
![]() |
提出日時 | 2018-03-13 14:20:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,056 bytes |
コンパイル時間 | 2,025 ms |
コンパイル使用メモリ | 170,252 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 23:06:56 |
合計ジャッジ時間 | 3,198 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define fst(t) std::get<0>(t)#define snd(t) std::get<1>(t)#define thd(t) std::get<2>(t)#define unless(p) if(!(p))#define until(p) while(!(p))using ll = long long;using P = std::tuple<int,int>;const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};int x, y;int N;int ds[20];int main(){std::cin.tie(nullptr);std::ios::sync_with_stdio(false);std::cin >> N;for(int i=0;i<N;++i){std::cin >> ds[i];}sort(ds, ds+N);std::cin >> x >> y;if(x == 0 && y == 0){std::cout << 0 << std::endl;return 0;}x = abs(x);y = abs(y);if(x > y){swap(x, y);}int mx_d = ds[N-1];int res;if(y < mx_d){res = 3;for(int i=0;i<N;++i){for(int j=i;j<N;++j){for(int s=-1;s<=1;s+=2){for(int t=-1;t<=1;t+=2){for(int w=0;w<4;++w){int a[2] = {ds[i], ds[j]}, b[2] = {s, t};int ls[2], rs[2];fill(ls, ls+2, 0);fill(rs, rs+2, 0);for(int k=0;k<2;++k){int idx = w >> k & 1;ls[idx] += a[k] * b[k];rs[idx] += a[k] * b[k];ls[!idx] -= a[k];rs[!idx] += a[k];}if(ls[0] <= x && x <= rs[0] && ls[1] <= y && y <= rs[1]){res = 2;}}}}}}for(int i=0;i<N;++i){if(x <= ds[i] && y == ds[i]){res = 1;}}}else{res = max((x + mx_d - 1) / mx_d, (y + mx_d - 1) / mx_d);}std::cout << res << std::endl;}