結果

問題 No.467 隠されていたゲーム
ユーザー tottoripapertottoripaper
提出日時 2018-03-13 14:20:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,056 bytes
コンパイル時間 1,913 ms
コンパイル使用メモリ 170,000 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 17:37:42
合計ジャッジ時間 2,828 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0