結果

問題 No.173 カードゲーム(Medium)
ユーザー 沙耶花沙耶花
提出日時 2021-11-03 16:49:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 941 ms / 3,000 ms
コード長 1,179 bytes
コンパイル時間 5,304 ms
コンパイル使用メモリ 258,640 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 08:12:57
合計ジャッジ時間 11,272 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
6,812 KB
testcase_01 AC 108 ms
6,944 KB
testcase_02 AC 744 ms
6,944 KB
testcase_03 AC 746 ms
6,940 KB
testcase_04 AC 719 ms
6,944 KB
testcase_05 AC 584 ms
6,940 KB
testcase_06 AC 410 ms
6,944 KB
testcase_07 AC 322 ms
6,940 KB
testcase_08 AC 319 ms
6,940 KB
testcase_09 AC 941 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 2000000000

unsigned long xor128() {
	static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
	unsigned long t=(x^(x<<11));
	x=y; y=z; z=w;
	return (w=(w^(w>>19))^(t^(t>>8)));
}

int main(){	
	
	int N;
	cin>>N;
	int Pa,Pb;
	{
		double t;
		cin>>t;
		t *= 1000;
		Pa = round(t);
	}
	{
		double t;
		cin>>t;
		t *= 1000;
		Pb = round(t);
	}
	vector<int> a(N),b(N);
	rep(i,N){
		cin>>a[i];
	}
	rep(i,N){
		cin>>b[i];
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	double ans = 0.0;
	rep(i,1000000){
		
		auto aa = a,bb = b;
		int Sa = 0,Sb = 0;
		rep(j,N){
			int x,y;
			if(j==N-1||xor128()%1000<Pa)x = 0;
			else x = xor128()%(N-1-j)+1;
			if(j==N-1||xor128()%1000<Pb)y = 0;
			else y = xor128()%(N-1-j)+1;
			if(aa[x]>bb[y]){
				Sa += aa[x]+bb[y];
			}
			else{
				Sb += aa[x]+bb[y];
			}
			aa.erase(aa.begin()+x);
			bb.erase(bb.begin()+y);
			
		}
		if(Sa>Sb){
			ans += 1.0 / 1000000.0;
		}
	}
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	return 0;
	
}
0