結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2018-12-26 14:03:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 755 ms |
コンパイル使用メモリ | 76,320 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 14:42:45 |
合計ジャッジ時間 | 1,464 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <algorithm>#include <iostream>#include <vector>using namespace std;size_t factorial(size_t a) {size_t tmp = 1;for (size_t i = 2; i <= a; ++i) tmp *= i;return tmp;}int main() {double sum = 0;size_t N, tmp;cin >> N;vector<int> A(N), B(N);for (size_t i = 0; i < N; ++i) cin >> A[i];for (size_t i = 0; i < N; ++i) cin >> B[i];sort(A.begin(), A.end());do {sort(B.begin(), B.end());do {tmp = 0;for (size_t i = 0; i < N; ++i) {if (A[i] > B[i]) ++tmp;}if (tmp > N / 2) ++sum;} while (next_permutation(B.begin(), B.end()));} while (next_permutation(A.begin(), A.end()));tmp = factorial(N);cout << sum / tmp / tmp;}