結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2024-09-04 18:12:43 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,519 bytes |
コンパイル時間 | 3,902 ms |
コンパイル使用メモリ | 282,388 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-04 18:12:49 |
合計ジャッジ時間 | 5,320 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using ull = unsigned long long;#define pb push_back#define rep(i, n) for (int i = 0; i < (n); i++)#define reps(i, n) for (int i = 1; i <= (n); i++)#define for_(i, a, b) for (int i = (a); i < (b); i++)#define all(v) v.begin(), v.end()#define Yes(b) ((b) ? "Yes" : "No")#define YES(b) ((b) ? "YES" : "NO")template <typename T>inline bool chmin(T &a, const T &b){bool compare = a > b;if (a > b)a = b;return compare;}template <typename T>inline bool chmax(T &a, const T &b){bool compare = a < b;if (a < b)a = b;return compare;}template <typename T>T gcd(T a, T b){if (b == 0)return a;elsereturn gcd(b, a % b);}template <typename T>inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }template <typename T>inline T ceil(T a, T b) { return (a + (b - 1)) / b; }template <typename T>inline T floor(T a, T b) { return a / b; }int main(){int N;cin >> N;vector<int> A(N);rep(i, N){cin >> A[i];}vector<int> B(N);rep(i, N){cin >> B[i];}sort(all(A));sort(all(B));ll ans = 0;ll sum = 0;do{vector<int> B_copy = B;do{int cnt = 0;rep(i, N){if (A[i] > B[i])cnt++;}if (cnt > N / 2){ans++;}sum++;} while (next_permutation(all(B_copy)));} while (next_permutation(all(A)));cout << (double)ans / (double)sum << endl;return 0;}