結果

問題 No.173 カードゲーム(Medium)
ユーザー te-shte-sh
提出日時 2016-09-14 16:56:21
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 1,014 bytes
コンパイル時間 3,128 ms
コンパイル使用メモリ 174,620 KB
実行使用メモリ 8,740 KB
最終ジャッジ日時 2023-09-02 22:09:03
合計ジャッジ時間 8,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
8,740 KB
testcase_01 AC 600 ms
4,368 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.regex, std.conv, std.stdio, std.typecons;

const auto rep = 10 ^^ 6;

void main()
{
  auto rd = readln.split;
  auto n = rd[0].to!size_t, pa = rd[1].to!real, pb = rd[2].to!real;
  auto ai = readln.split.map!(to!int).array;
  auto bi = readln.split.map!(to!int).array;

  ai.sort();
  bi.sort();

  auto r = 0;
  foreach (_; 0..rep) {
    auto wa = 0, wb = 0;
    auto aj = ai.dup, bj = bi.dup;
    foreach (i; 0..n) {
      int a = pickup(aj, pa);
      int b = pickup(bj, pb);
      if (a > b) wa += a + b;
      else wb += a + b;
    }
    if (wa > wb) r += 1;
  }

  writeln(r.to!real / rep);
}

int pickup(ref int[] ai, real p)
{
  int a;
  if (ai.length == 1 || uniform(0.0L, 1.0L) <= p) {
    a = ai.front;
    ai = ai[1..$];
  } else {
    auto i = uniform(1, ai.length);
    a = ai[i];
    ai = ai[0..i] ~ ai[i+1..ai.length];
  }
  return a;
}
0