結果

問題 No.173 カードゲーム(Medium)
ユーザー 👑 kmjpkmjp
提出日時 2015-03-27 00:37:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 423 ms / 3,000 ms
コード長 1,358 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 150,928 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 10:34:51
合計ジャッジ時間 5,190 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
4,380 KB
testcase_01 AC 92 ms
4,376 KB
testcase_02 AC 371 ms
4,380 KB
testcase_03 AC 372 ms
4,384 KB
testcase_04 AC 361 ms
4,376 KB
testcase_05 AC 331 ms
4,384 KB
testcase_06 AC 298 ms
4,380 KB
testcase_07 AC 281 ms
4,376 KB
testcase_08 AC 279 ms
4,384 KB
testcase_09 AC 423 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,T;
double P[2];
int A[30],B[30];
int win,tot;

vector<int> getrandvec(double p) {
	int i,x;
	vector<int> v,r;
	FOR(i,N) v.push_back(i);
	FOR(i,N-1) {
		double d = rand()*1.0/RAND_MAX;
		if(d<p) x=0;
		else x=1+(N-1-i)*(d-p)/(1-p);
		
		r.push_back(v[x]);
		v.erase(v.begin()+x);
	}
	r.push_back(v[0]);
	return r;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>P[0]>>P[1];
	FOR(i,N) cin>>A[i], T+=A[i];
	FOR(i,N) cin>>B[i], T+=B[i];
	sort(A,A+N);
	sort(B,B+N);
	
	srand(time(NULL));
	
	FOR(i,200000) {
		tot++;
		vector<int> VA,VB;
		VA=getrandvec(P[0]);
		VB=getrandvec(P[1]);
		x=0;
		FOR(y,N) if(A[VA[y]]>B[VB[y]]) x+=A[VA[y]]+B[VB[y]];
		if(x>T/2) win++;
	}
	
	_P("%.12lf\n",1.0*win/tot);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0