結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2020-11-29 20:32:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 814 bytes |
コンパイル時間 | 2,008 ms |
コンパイル使用メモリ | 171,996 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-13 02:08:22 |
合計ジャッジ時間 | 3,197 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i,k,n) for(int i = k;i < (n);i++) typedef long long ll; typedef pair <int,int> P; const ll MOD = 1e9 + 7; const int INF = 1e8; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; int main(void){ int n; double gamewin = 0,matchnum = 0,ans; cin >> n; vector<int> a(n),b(n); rep(i,n) cin >> a.at(i); rep(i,n) cin >> b.at(i); sort(a.begin(),a.end()); do { int win = 0; rep(i,n){ if(a[i] > b[i]) win++;//カードの数で勝利 } if(win > n/2) gamewin++;//試合で勝利 matchnum++; } while (next_permutation(a.begin(),a.end())); ans = gamewin/matchnum; cout << ans << endl; }