結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2021-02-21 14:43:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 1,683 ms |
コンパイル使用メモリ | 173,652 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 13:01:26 |
合計ジャッジ時間 | 2,774 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#define MOD 1000000007#define INF 500000000#define rep(i,n) for(int i=0;i<n;i++)#define READ(a,n) for(int i=0;i<n;i++) std::cin >> a[i]// めも 1行で要素数の同じ複数の配列の要素が同時に与えられるとき// READ(a,n) >> b[i];のように使用#define RST(a,n,x) for(int i=0;i<n;i++) a[i]=xusing namespace std;using ll=long long;using P=pair<int,int>;int dx[]={0,-1,1,0},dy[]={-1,0,0,1};//int dx[]={-1,0,1,-1,1,-1,0,1},dy[]={-1,-1,-1,0,0,1,1,1};int main(void){int n;cin >> n;vector<int> a(n),b(n);READ(a,n); READ(b,n);int ans=0;sort(a.begin(),a.end());do {int w=0;rep(i,n) {if(a[i]>b[i]) w++;}if(w>n-w) {ans++;}} while(next_permutation(a.begin(),a.end()));int x=1;rep(i,n) x*=n-i;cout << fixed << setprecision(3) << (double)ans/x << endl;return 0;}