結果

問題 No.133 カードゲーム
ユーザー suzuishisuzuishi
提出日時 2021-02-21 14:43:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 912 bytes
コンパイル時間 1,601 ms
コンパイル使用メモリ 173,060 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 16:40:51
合計ジャッジ時間 2,646 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]=x
using 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;
}
0