結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2020-07-03 21:03:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,614 bytes |
コンパイル時間 | 1,625 ms |
コンパイル使用メモリ | 173,188 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-16 21:30:50 |
合計ジャッジ時間 | 2,734 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#pragma region Template#include <bits/stdc++.h>using namespace std;struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;#define REP(i, n) for(int i = 0; i < n; i++)#define RNG(i, a, b) for(int i = a; i < b; i++)#define RBF(i, v) for(auto& i : v)#define ALL(x) x.begin(), x.end()using LL = long long;using UL = unsigned long;using ULL = unsigned long long;template<typename T> using V = vector<T>;template<typename T> using VV = vector<vector<T>>;template<typename T> using P = pair<T, T>;const double PI = 3.141592653589793;const int MOD = 1000000007;const LL INF64 = static_cast<LL>(1e18) + 2;const int INF = static_cast<int>(1e9) + 2;template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }template<typename T> inline void col(T x) { cout << x << '\n'; }template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }#pragma endregionsigned main(){int n;cin >> n;vector<int> a(n), b(n);for (auto& ai : a) cin >> ai;for (auto& bi : b) cin >> bi;sort(a.begin(), a.end());sort(b.begin(), b.end());vector<int> b0(b);int win = 0, all = 0;do {b = b0;do {int awin = 0, bwin = 0;for (int i = 0; i < n; i++) {if (a[i] > b[i]) awin++;else bwin++;}if (awin > bwin) win++;all++;} while (next_permutation(b.begin(), b.end()));} while (next_permutation(a.begin(), a.end()));cout << static_cast<double>(win) / all << '\n';return 0;}