結果
問題 | No.173 カードゲーム(Medium) |
ユーザー | tottoripaper |
提出日時 | 2015-07-27 23:24:51 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,384 bytes |
コンパイル時間 | 615 ms |
コンパイル使用メモリ | 71,264 KB |
実行使用メモリ | 4,508 KB |
最終ジャッジ日時 | 2023-09-23 04:10:55 |
合計ジャッジ時間 | 3,074 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
4,380 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 177 ms
4,376 KB |
testcase_06 | AC | 140 ms
4,376 KB |
testcase_07 | AC | 122 ms
4,380 KB |
testcase_08 | AC | 120 ms
4,380 KB |
testcase_09 | AC | 267 ms
4,380 KB |
ソースコード
#include <cstdio> #include <vector> #include <random> #include <algorithm> const int T = 160000; int N; double PA, PB; int A[20], B[20]; std::vector<int> va, vb; std::random_device randomDevice; std::mt19937 engine(randomDevice()); int simulate(int point_a, int point_b){ if(va.empty()){ return point_a > point_b; } int index, index2; if(va.size() == 1 || engine() % 1000 < PA * 1000){ index = 0; }else{ index = engine() % va.size(); } if(vb.size() == 1 || engine() % 1000 < PB * 1000){ index2 = 0; }else{ index2 = engine() % vb.size(); } int point = va[index] + vb[index2]; if(va[index] > vb[index2]){ point_a += point; }else if(va[index] < vb[index2]){ point_b += point; } va.erase(va.begin() + index); vb.erase(vb.begin() + index2); return simulate(point_a, point_b); } int main(){ scanf("%d %lf %lf", &N, &PA, &PB); for(int i=0;i<N;i++){ scanf("%d", A+i); } for(int i=0;i<N;i++){ scanf("%d", B+i); } std::sort(A, A+N); std::sort(B, B+N); double res = 0.0; for(int i=0;i<T;i++){ va.resize(N); vb.resize(N); std::copy(A, A+N, va.begin()); std::copy(B, B+N, vb.begin()); res += simulate(0, 0); } printf("%.6f\n", 1. * res / T); }