結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-13 21:59:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 688 bytes |
| コンパイル時間 | 520 ms |
| コンパイル使用メモリ | 60,116 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 11:14:57 |
| 合計ジャッジ時間 | 1,370 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
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];
}
int ans = 0;
int cnt = 0;
sort(a, a + n);
do {
for (int i = 0; i < n; ++i) {
if (a[i] > b[i]) {
cnt++;
}
}
if (cnt > n / 2) {
ans++;
}
cnt = 0;
} while (next_permutation(a, a + n));
int sum = 1;
for (int i = n; i >= 2; --i) {
sum *= i;
}
//cout << ans << " " << sum << endl;
cout << (double)ans / sum << endl;
}