結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
kira924age
|
| 提出日時 | 2021-08-31 22:10:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 747 ms |
| コンパイル使用メモリ | 75,152 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-26 08:44:58 |
| 合計ジャッジ時間 | 1,595 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<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];
}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
double ans = 0;
int c = 0;
do {
do {
c++;
int cnt1 = 0, cnt2 = 0;
for (int i = 0; i < n; i++) {
cnt1 += (a[i] > b[i]);
cnt2 += (a[i] < b[i]);
}
ans += (cnt1 > cnt2);
} while (next_permutation(b.begin(), b.end()));
} while (next_permutation(a.begin(), a.end()));
ans /= c;
cout << ans << "\n";
return 0;
}
kira924age