結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2020-03-16 17:17:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,703 bytes |
コンパイル時間 | 1,788 ms |
コンパイル使用メモリ | 173,464 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 02:54:41 |
合計ジャッジ時間 | 2,299 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using pii = pair<int, int>;using pll = pair<ll, ll>;#define ull unsigned long long#define ld long doubletemplate <class T>using V = vector<T>;template <class T>using VV = V<V<T>>;template <class T>using VVV = V<V<V<T>>>;#define rep2(i, a, b) for (int i = (a); i < (b); ++i)#define rep(i, n) rep2(i, 0, n)#define rep1(i, n) rep1(i, 1, n + 1)// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)#define sz(x) ((int)(x).size())#define all(x) (x).begin(), (x).end()#define rall(x) (x).rbegin(), (x).rend() //#define SORT(v, n) sort(v, v + n);#define VSORT(v) sort(v.begin(), v.end());#define RSORT(x) sort(rall(x));#define INF (1e9)#define PI (acos(-1))#define EPS (1e-7)// 総数を1000000007(素数)で割った余りconst long long mod = 1e9 + 7;const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};const int dy[] = {1, 0, -1, 0, -1, 1, 1, -1};ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }int fact(int n) {if (n == 0) return 1;return fact(n - 1) * n;}int main() {cin.tie(0);ios::sync_with_stdio(false);cout << std::fixed << std::setprecision(15);// cout << std::setfill('0') << std::setw(2);int n;cin >> n;V<int> a(n), b(n);rep(i, n) cin >> a[i];rep(i, n) cin >> b[i];sort(all(a));int ans = 0;do {int win = 0;rep(i, n) if (a[i] > b[i]) win++;if (win > n / 2) ans++;} while (next_permutation(all(a)));cout << 1. * ans / fact(n) << endl;return 0;}