結果

問題 No.173 カードゲーム(Medium)
ユーザー gigurururugigurururu
提出日時 2015-03-27 00:18:26
言語 Ruby
(3.2.2)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 509 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 11,280 KB
実行使用メモリ 15,404 KB
最終ジャッジ日時 2023-08-25 01:36:24
合計ジャッジ時間 1,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require'timeout'
n,pa,pb=gets.split.map(&:to_f)
n=n.to_i
a,b=$<.map{|l|l.split.map(&:to_i).sort}

sum=0.0
cnt=0
begin
  timeout(2.9){
    loop{
      al=a.dup
      bl=b.dup
      ap=bp=0
      n.times{
        at=al.delete_at(al[1]&&rand>pa ?([*1..al.size-1].sample):0)
        bt=bl.delete_at(bl[1]&&rand>pb ?([*1..bl.size-1].sample):0)
        if at>bt
          ap+=at+bt
        else
          bp+=at+bt
        end
      }
      sum+=1 if ap>bp
      cnt+=1
    }
  }
rescue Timeout::Error
end
p sum/cnt
0