結果
| 問題 |
No.1267 Stop and Coin Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-23 23:23:32 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 831 bytes |
| コンパイル時間 | 768 ms |
| コンパイル使用メモリ | 130,424 KB |
| 実行使用メモリ | 7,884 KB |
| 最終ジャッジ日時 | 2024-06-22 09:47:03 |
| 合計ジャッジ時間 | 2,527 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 43 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdlib, std.datetime;
void main() {
auto s = readln.split.map!(to!long);
auto N = s[0].to!int;
auto V = s[1];
auto A = readln.split.map!(to!long).array;
if (A.sum <= V) {
writeln("Draw");
return;
}
auto mem = new int[](1 << N);
mem[] = -1;
int rec(int mask, long vol) {
if (mem[mask] != -1) return mem[mask];
if (vol > V) return mem[mask] = 1;
mem[mask] = 0;
foreach (i; 0..N) if (!(mask & (1 << i))) {
mem[mask] |= !rec(mask | (1 << i), vol + A[i]);
}
return mem[mask];
}
writeln(rec(0, 0) ? "First" : "Second");
}