結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-20 20:01:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 112 ms / 2,000 ms |
| コード長 | 1,047 bytes |
| コンパイル時間 | 794 ms |
| コンパイル使用メモリ | 94,204 KB |
| 実行使用メモリ | 7,560 KB |
| 最終ジャッジ日時 | 2024-07-17 13:47:28 |
| 合計ジャッジ時間 | 3,455 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int dp[1050000] = { 0 };
long long a[22];
int main() {
long long n, v;
cin >> n >> v;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < (1 << n); i++) {
long long sum = 0;
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
sum += a[j];
}
}
if (sum > v) {
dp[i] = 1;
}
}
if (dp[(1 << n) - 1] == 0) {
cout << "Draw" << endl;
return 0;
}
for (int i = (1 << n) - 1; i >= 0; i--) {
if (dp[i] == 0) {
bool bo = false;
for (int j = 0; j < n; j++) {
if (!(i & (1 << j))) {
if (dp[i + (1 << j)] == -1) {
bo = true;
}
}
}
if (bo) {
dp[i] = 1;
}
else {
dp[i] = -1;
}
}
}
if (dp[0] == 1) {
cout << "First" << endl;
}
else {
cout << "Second" << endl;
}
}