結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-09-11 21:37:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 889 bytes |
コンパイル時間 | 1,585 ms |
コンパイル使用メモリ | 169,548 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 16:52:53 |
合計ジャッジ時間 | 2,388 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#define FOR(i,a,b) for (int (i) = (a); (i) < (b); ++(i))#define rep(i,n) for (int (i) = 0; (i) < (n); ++(i))#define rrep(i,n) for (int (i) = (n); (i) >= 0; --(i))#define all(x) (x).begin(), (x).end()using namespace std;typedef long long ll;const int INF = 1e9;const ll LINF = 1LL << 60;const ll MOD = 1e9 + 7;int N, A[4], B[4];int main() {cin >> N;rep(i,N) cin >> A[i];rep(i,N) cin >> B[i];sort(A, A+N);sort(B, B+N);int awin = 0;int ap = 0;do {do {++ap;int rawin = 0;rep(i,N) {if (A[i] > B[i]) ++rawin;}if (2*rawin > N) ++awin;} while (next_permutation(B, B+N));} while (next_permutation(A, A+N));double p = (double)awin / (double)ap;cout << fixed << setprecision(10) << p << "\n";return 0;}