結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2022-05-05 10:45:47 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 768 bytes |
コンパイル時間 | 759 ms |
コンパイル使用メモリ | 75,308 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-04 12:14:41 |
合計ジャッジ時間 | 1,680 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>#include<map>#include<set>#include<cmath>#include<queue>#include<stack>#include<string>#define rep(i,n) for(int i=0;i<(n);i++)using ll = long long;using namespace std;int main() {int n;cin >> n;vector<int> a(n), b(n);rep(i, n) cin >> a[i];rep(i, n) cin >> b[i];vector<int> da(n), db(n);rep(i, n) da[i] = i;int num = 0, win = 0;do {rep(i, n) db[i] = i;do {num++;int wina = 0, winb = 0;rep(i, n) {if (a[da[i]] > b[db[i]]) wina++;else winb++;}if (wina > winb) win++;} while (next_permutation(db.begin(), db.end()));} while (next_permutation(da.begin(), da.end()));double ans = (double)win / (double)num;printf("%.4f", ans);return 0;}