結果

問題 No.1267 Stop and Coin Game
ユーザー mencotton
提出日時 2020-11-02 15:34:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 752 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 76,140 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-22 06:17:52
合計ジャッジ時間 4,666 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 TLE * 1 -- * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

ll n, v;
vector<ll> a;

bool func(ll remain, vector<bool> used) {
    bool canWin = false;
    for (int i = 0; i < n; i++) {
        if (!used[i] && remain >= a[i]) {
            used[i] = true;
            if (!func(remain - a[i], used))canWin = true;
            used[i] = false;
        }
    }
    return canWin;
}

int main() {
    cin >> n >> v;
    a.resize(n);
    for (int i = 0; i < n; i++)cin >> a[i];

    ll sum = 0;
    for (int i = 0; i < n; i++)sum += a[i];
    if (sum <= v) {
        cout << "Draw" << endl;
        return 0;
    }

    vector<bool> tmp(n);
    cout << (func(v, tmp) ? "First" : "Second") << endl;
    return 0;
}
0