結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-07 15:55:32 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,033 bytes |
| コンパイル時間 | 2,967 ms |
| コンパイル使用メモリ | 163,200 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 06:57:37 |
| 合計ジャッジ時間 | 6,411 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 2 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.random; // random
const auto iter = 100_000;
void main()
{
auto rd = readln.split, n = rd[0].to!size_t;
auto pa = (rd[1].to!real * 1000).to!int, pb = (rd[2].to!real * 1000).to!int;
auto ai = readln.split.to!(int[]);
auto bi = readln.split.to!(int[]);
ai.sort(); bi.sort();
Random rnd;
auto selectCard(ref int[] ci, int pc) {
int c;
if (ci.length == 1 || uniform(0, 1000, rnd) <= pc) {
c = ci.front;
ci = ci.remove(0);
} else {
auto i = uniform(1, ci.length);
c = ci[i];
ci = ci.remove(i);
}
return c;
}
auto calc() {
auto pta = 0, ptb = 0;
auto ai2 = ai.dup, bi2 = bi.dup;
while (!ai2.empty) {
auto a = selectCard(ai2, pa);
auto b = selectCard(bi2, pb);
if (a > b) pta += a + b;
else if (a < b) ptb += a + b;
}
return pta > ptb;
}
auto r = 0;
foreach (_; iter.iota)
if (calc) ++r;
writefln("%.3f", r.to!real / iter);
}