結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2024-04-28 19:46:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 676 bytes |
コンパイル時間 | 1,698 ms |
コンパイル使用メモリ | 171,928 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 14:55:05 |
合計ジャッジ時間 | 2,773 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { 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); } double cnt=0; double total=0; sort(a.begin(), a.end()); do { sort(b.begin(), b.end()); do { int win_a=0, win_b=0; for (int i=0; i<n; i++) { if (a.at(i) > b.at(i)) win_a++; if (b.at(i) > a.at(i)) win_b++; } if (win_a > win_b) cnt++; total++; } while (next_permutation(b.begin(), b.end())); } while (next_permutation(a.begin(), a.end())); double prob = cnt / total; cout << prob << endl; }