結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2024-08-09 16:14:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 917 bytes |
コンパイル時間 | 1,641 ms |
コンパイル使用メモリ | 169,224 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-08-09 16:14:53 |
合計ジャッジ時間 | 2,637 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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[i]; } for(int i = 0; i < N; i++) { cin >> B[i]; } int nBattle = 0; int nWin = 0; vector<int> PermA(N), PermB(N); for(int i = 0; i < N; i++) { PermA[i] = i; PermB[i] = i; } do { do { int cntAWin = 0; for(int i = 0; i < N; i++) { if(A[PermA[i]] > B[PermB[i]]) { cntAWin++; } } int BWin = N-cntAWin; if(cntAWin > BWin) { nWin++; } nBattle++; } while (next_permutation(PermB.begin(), PermB.end())); } while (next_permutation(PermA.begin(), PermA.end())); double Ans = 1.0 * nWin / nBattle; cout << Ans << endl; }