結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-14 15:28:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 1,543 ms |
| コンパイル使用メモリ | 169,252 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-27 10:54:02 |
| 合計ジャッジ時間 | 2,448 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
int n;
cin >> n;
vector<int> A(n);
vector<int> B(n);
rep(i, n) {
cin >> A[i];
}
rep(i, n) {
cin >> B[i];
}
vector<int> ind(n);
rep(i, n) {
ind[i] = i;
}
int all = 0, win = 0, a = 0;
do {
a = 0;
rep(i, n) {
if(A[ind[i]] > B[i]) a++;
if(A[ind[i]] < B[i]) a--;
}
if (a > 0) win++;
all++;
} while (next_permutation(ind.begin(), ind.end()));
cout << (double)win/all << endl;
return 0;
}