結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2020-05-08 15:00:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,323 bytes |
コンパイル時間 | 1,598 ms |
コンパイル使用メモリ | 175,440 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 09:51:12 |
合計ジャッジ時間 | 2,306 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h>#define FOR(i,a,b) for(int i=(a);i<(b);i++)#define REP(i,n) for(int i=0;i < (n);i++)#define ALL(obj) (obj).begin(),(obj).end()#define SCANF(i) int i;scanf("%d",&i)using namespace std;using P = pair<int,int>;const long long INF = 1LL << 60;const int IINF=100000000;const int MOD = (int)1e9 + 7;typedef long long ll;//約数列挙vector<long long> divisor(long long n) {vector<long long> ret;for (long long i = 1; i * i <= n; i++) {if (n % i == 0) {ret.push_back(i);if (i * i != n) ret.push_back(n / i);}}//sort(ret.begin(), ret.end()); // 昇順に並べるreturn ret;}vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};signed main () {int n;cin >> n;vector<int> lista(n);vector<int> listb(n);REP(i,n)cin >> lista[i];REP(j,n)cin >> listb[j];sort(ALL(lista));sort(ALL(listb));double cnt = 0;double allcnt = 0;do{do{int tmpcnt = 0;REP(i,n){if(lista[i]>listb[i])tmpcnt++;}if(n-tmpcnt<tmpcnt)cnt++;allcnt++;}while(next_permutation(ALL(listb)));}while(next_permutation(ALL(lista)));double ans = cnt / allcnt;cout << ans << endl;}