結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-06 14:55:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 772 bytes |
| コンパイル時間 | 1,481 ms |
| コンパイル使用メモリ | 173,760 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-19 17:19:48 |
| 合計ジャッジ時間 | 2,255 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
//input
int n;
cin>>n;
vector<int>a(n);
vector<int>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());//next_permutationで全順列を出すときは昇順である必要があるらしい
//nが4までなのでaの全順列を列挙し比較
double ans;
int wingame=0;
int cntgame=0;
do{
int wincard=0;
for(int i=0;i<n;i++){
if(a[i]>b[i])wincard++;
else wincard--;
}
if(wincard>0) wingame++;
cntgame++;
}while(next_permutation(a.begin(),a.end()));
//output
double Wing=wingame;
double Cntg=cntgame;
ans=Wing/Cntg;
cout<<fixed<<setprecision(5)<<ans<<endl;
return 0;}