結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2020-04-24 21:14:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 857 bytes |
コンパイル時間 | 8,252 ms |
コンパイル使用メモリ | 172,276 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-15 02:10:15 |
合計ジャッジ時間 | 2,348 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i, n) for (int i = 0; i < (int)(n); i++)typedef long long ll;typedef pair<int, int> P;const ll mod = 1000000007; //出力は (ans % mod + mod) % mod (負の剰余を正にする)const int inf = 1e9;const long long INF = 1LL << 60; // INF = 1152921504606846976int dx[4] = {-1,0,0,1};int dy[4] = {0,-1,1,0};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];sort(a.begin(),a.end());sort(b.begin(),b.end());int cnt = 0;int win = 0;do{int big = 0;cnt++;rep(i,n){if(a[i] > b[i]) big++;}if(big > n/2) win++;}while(next_permutation(a.begin(),a.end()));double ans = (double)win/(double)(cnt);cout << ans << endl;}