結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-01-22 23:39:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 500 ms |
| コンパイル使用メモリ | 66,808 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 03:26:29 |
| 合計ジャッジ時間 | 1,292 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
int factorial(int n) {
if (n == 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}
int main() {
int n;
cin >> n;
vector<int> a(n, 0), b(n, 0), order(n , 0);
for (int i = 0; i < n; i++) {
cin >> a[i];
order[i] = i;
}
for (int i = 0; i < n; i++) {
cin >> b[i];
}
int total_win = 0;
do {
int wins = 0;
for (int i = 0; i < n; i++) {
if (a[i] > b[order[i]]) {
wins++;
}
}
if (wins > n / 2) {
total_win++;
}
} while (next_permutation(order.begin(), order.end()));
double ans = 1.0 * total_win / factorial(n);
printf("%.3f\n", ans);
return 0;
}