結果
問題 | No.173 カードゲーム(Medium) |
ユーザー | fiord |
提出日時 | 2015-08-30 01:05:42 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,984 ms / 3,000 ms |
コード長 | 806 bytes |
コンパイル時間 | 1,639 ms |
コンパイル使用メモリ | 165,632 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 15:37:34 |
合計ジャッジ時間 | 23,485 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n; double pa,pb; int tries=0,scs=0; bool game(vector<int> a,vector<int> b){ int ap=0,bp=0; while(a.size()>0){ int aa,bb; if(rand()%1000<pa*1000||a.size()==1) aa=0; else aa=1+rand()%((int)a.size()-1); if(rand()%1000<pb*1000||b.size()==1) bb=0; else bb=1+rand()%((int)b.size()-1); if(a[aa]>b[bb]) ap+=a[aa]+b[bb]; else bp+=a[aa]+b[bb]; a.erase(a.begin()+aa); b.erase(b.begin()+bb); } if(ap>bp) return true; else return false; } int main(){ cin>>n>>pa>>pb; vector<int> a(n),b(n); for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>b[i]; sort(a.begin(),a.end()); sort(b.begin(),b.end()); auto start=time(NULL); while(time(NULL)-start<2){ tries++; if(game(a,b)) scs++; } cout<<(double)scs/tries<<endl; return 0; }