結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-07-30 13:32:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 664 bytes |
コンパイル時間 | 1,573 ms |
コンパイル使用メモリ | 161,108 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 13:46:15 |
合計ジャッジ時間 | 2,070 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; float fac(int n){ if(n<2) return 1; return n*fac(n-1); } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin>>n; int a[n],b[n]; for (int i = 0; i < n; i++)cin>>a[i]; for (int i = 0; i < n; i++)cin>>b[i]; float ans=0; sort(a,a+n); sort(b,b+n); do{ do{ int ac=0,bc=0; for (int i = 0; i < n; i++){ if(a[i]>b[i])ac++; else bc++; } if(ac>bc)ans++; }while(next_permutation(b,b+n)); sort(b,b+n); }while(next_permutation(a,a+n)); cout<<ans/(fac(n)*fac(n))<<'\n'; }