結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2018-02-27 06:51:19 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 755 bytes |
コンパイル時間 | 1,566 ms |
コンパイル使用メモリ | 163,672 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-25 04:20:44 |
合計ジャッジ時間 | 2,449 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using pii = pair<int, int>;int main() {cin.tie(0);ios_base::sync_with_stdio(false);cout << fixed << setprecision(10);int N;cin >> N;vector<int> a(N), b(N);for (int i = 0; i < N; i++) {cin >> a[i];}for (int i = 0; i < N; i++) {cin >> b[i];}sort(a.begin(), a.end());sort(b.begin(), b.end());int all = 0, win = 0;do {vector<int> c = b;do {int num = 0;for (int i = 0; i < N; i++) {num += a[i] > c[i];}win += num * 2 > N;all++;} while (next_permutation(c.begin(), c.end()));} while (next_permutation(a.begin(), a.end()));cout << 1. * win / all << endl;return 0;}