結果

問題 No.133 カードゲーム
ユーザー hima_prorohima_proro
提出日時 2020-11-29 20:32:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 814 bytes
コンパイル時間 1,675 ms
コンパイル使用メモリ 171,096 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 02:36:23
合計ジャッジ時間 3,753 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,368 KB
testcase_05 AC 2 ms
4,372 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 1 ms
4,372 KB
testcase_09 AC 2 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 1 ms
4,368 KB
testcase_15 AC 1 ms
4,372 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 AC 2 ms
4,368 KB
testcase_18 AC 1 ms
4,372 KB
testcase_19 AC 2 ms
4,368 KB
testcase_20 AC 1 ms
4,368 KB
testcase_21 AC 1 ms
4,368 KB
testcase_22 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

}
0