結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2022-02-17 11:52:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,405 bytes |
コンパイル時間 | 2,199 ms |
コンパイル使用メモリ | 200,004 KB |
最終ジャッジ日時 | 2025-01-27 23:27:26 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>typedef int64_t ll;using namespace std;#define dump(x) cout << #x << " = " << (x) << endl;// #define dump(x) ;template <class T>inline bool chmin(T &a, T b) {if (a > b) {a = b;return true;}return false;}double solve(int n, vector<int> a, vector<int> b) {// next_permutaion の引数はソート済みである必要があるstd::sort(a.begin(), a.end());ll total = 0;ll a_win = 0;do {int a_up = 0;for (int i = 0; i < n; i++) {if (a.at(i) > b.at(i)) {a_up++;}if (a.at(i) < b.at(i)) {a_up--;}}if (a_up > 0) {a_win++;}total++;// next_permutaion の引数はソート済みである必要がある} while (next_permutation(a.begin(), a.end()));return static_cast<double>(a_win) / static_cast<double>(total);}// generated by oj-template v4.8.1// (https://github.com/online-judge-tools/template-generator)int main() {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);int n;cin >> n;vector<int> a(n), b(n);for (int i = 0; i < n; i++) {cin >> a.at(i);}for (int i = 0; i < n; i++) {cin >> b.at(i);}auto ans = solve(n, a, b);std::cout << ans << '\n';return 0;}