結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2024-02-27 12:08:26 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 804 bytes |
コンパイル時間 | 10,389 ms |
コンパイル使用メモリ | 164,408 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-29 12:04:25 |
合計ジャッジ時間 | 4,152 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i = 0;i < (n); ++i)#define all(v) (v).begin(), (v).end()using ll = long long;int upstairs(int x) {if (x == 0) return 1;else return x * upstairs(x - 1);}int main() {int n, cnt = 0;cin >> n;vector<int> a(n), b(n);rep(i, n) cin >> a[i];rep(i, n) cin >> b[i];sort(all(a));sort(all(b));do {do {int acnt = 0, bcnt = 0;rep(i, n) {if(a[i] > b[i]) ++acnt;else if (a[i] < b[i]) ++bcnt;}if (acnt > bcnt) ++cnt;} while(next_permutation(all(b)));} while(next_permutation(all(a)));double ans;ans = cnt / pow(upstairs(n), 2);cout << ans << endl;return 0;}