結果

問題 No.133 カードゲーム
ユーザー kurenai3110kurenai3110
提出日時 2016-12-15 13:33:07
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 695 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 90,332 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 09:27:28
合計ジャッジ時間 2,246 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <random>
#include <ctime>
#include <functional>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
    int n;cin>>n;
    vector<int>a(n),b(n);
    
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];

    random_device rd;
    mt19937 mt(rd());
    
    int limit=100000;
    int win=0;
    for(int i=0;i<limit;i++){
        shuffle(a.begin(),a.end(),mt);
        shuffle(b.begin(),b.end(),mt);
        
        int cnt=0;
        for(int j=0;j<n;j++){
            if(a[j]>b[j])cnt++;
        }
        if(cnt>n/2)win++;
    }
    cout<<fixed<<setprecision(3)<<(double)win/limit<<endl;
    
    return 0;
}
0