結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-12 05:23:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,088 bytes |
| コンパイル時間 | 2,105 ms |
| コンパイル使用メモリ | 192,724 KB |
| 最終ジャッジ日時 | 2025-01-25 15:22:01 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 35 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long int A[20];
long long int N,V;
long long int sum[1<<20];
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> V;
for(int i=0;i<N;i++)
{
cin >> A[i];
}
for(int i=0;i<(1<<N);i++)
{
for(int j=0;j<N;j++)
{
if((i&(1<<j)))
{
sum[i] += A[j];
}
}
}
if(sum[(1<<N)-1] <= V)
{
cout << "Draw" << '\n';
return 0;
}
for(int i=0;i<(1<<N);i++)
{
int bitcnt = 0;
for(int j=0;j<N;j++)
{
if((i&(1<<j))) bitcnt++;
}
long long int MIN = 1e18;
for(int j=0;j<N;j++)
{
if((i&(1<<j))) continue;
MIN = min(MIN,A[j]);
}
if(sum[i] + MIN > V)
{
if(bitcnt%2)
{
cout << "First" << '\n';
}
else{
cout << "Second" << '\n';
}
break;
}
}
return 0;
}