結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-06-16 11:24:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,006 bytes |
コンパイル時間 | 1,883 ms |
コンパイル使用メモリ | 161,788 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 17:01:28 |
合計ジャッジ時間 | 2,759 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;int N;int A[4];int B[4];int permA[4], permB[4];double vicA = 0, games = 0;void permutation(int n) {for (int i = 0; i < n; i++) {permA[i] = A[i];}do {for (int i = 0; i < n; i++) {permB[i] = B[i];}do {double winA = 0, winB = 0;for (int j = 0; j < n; j++) {winA += (permA[j] > permB[j]);winB += (permA[j] < permB[j]);}vicA += (winA > winB);games++;} while (next_permutation(permB, permB + n));} while (next_permutation(permA, permA + n));return ;}int main() {cin >> N;double 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, a + N); sort(b, b + N);for (int i = 0; i < N; i++) A[i] = a[i], B[i] = b[i];permutation(N);double pA = vicA / games;cout << pA << endl;return 0;}