結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2019-08-04 16:55:35 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,320 bytes |
コンパイル時間 | 639 ms |
コンパイル使用メモリ | 86,516 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 10:28:28 |
合計ジャッジ時間 | 1,480 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <iostream>#include <vector>#include <string>#include <algorithm>#include <stack>#include <queue>#include <set>#include <map>#include<iomanip>using namespace std;#define rep(i,n) for(int i=0;i<n;i++)#define REP(i,a,n) for(int i=a;i<n;i++)typedef long long ll;template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }void Main(){int N; cin >> N;int a[5];int b[5];rep(i,N) cin >> a[i];rep(i,N) cin >> b[i];sort(a, a + N);sort(b, b + N);int game_cnt = 0;int win_cnt = 0;do {do {int inner_a_win_cnt = 0;int inner_b_win_cnt = 0;rep(i,N) {if (a[i] > b[i]) ++inner_a_win_cnt;if (b[i] > a[i]) ++inner_b_win_cnt;}if (inner_a_win_cnt > inner_b_win_cnt) ++win_cnt;++game_cnt;} while(next_permutation(b, b + N));} while(next_permutation(a, a + N));cout << ((double)win_cnt / (double)game_cnt) << endl;}int main(){cin.tie(nullptr);ios_base::sync_with_stdio(false);cout << fixed << setprecision(15);Main();}