結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-05 23:41:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 5,000 ms |
| コード長 | 1,240 bytes |
| コンパイル時間 | 2,073 ms |
| コンパイル使用メモリ | 199,456 KB |
| 最終ジャッジ日時 | 2025-01-14 07:19:36 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
// #define MAX 4
int n;
// int a[4];
// int b[4];
int factorial(int n) {
int ret = 1;
for (int i = 1; i <= n; i++) {
ret *= i;
}
return ret;
}
int main() {
cin >> n;
vector<int> a(n);
vector<int> b(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
}
for (int i = 0; i < n; i++) {
cin >> b.at(i);
}
sort(begin(a), end(a));
sort(begin(b), end(b));
int cnt = 0;
do {
do {
int cnt2 = 0;
for (int i = 0; i < n; i++) {
if (a.at(i) > b.at(i)) {
cnt2++;
}
}
if (cnt2 > n / 2) {
cnt++;
}
} while(next_permutation(begin(b), end(b)));
sort(begin(b), end(b));
} while(next_permutation(begin(a), end(a)));
double ans = cnt / pow(factorial(n), 2);
cout << fixed << setprecision(2) << ans << endl;
}