結果

問題 No.173 カードゲーム(Medium)
ユーザー h_nosonh_noson
提出日時 2016-05-07 18:24:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 180 ms / 3,000 ms
コード長 1,428 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 90,160 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 13:38:18
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,248 KB
testcase_01 AC 24 ms
5,376 KB
testcase_02 AC 155 ms
5,376 KB
testcase_03 AC 154 ms
5,376 KB
testcase_04 AC 152 ms
5,376 KB
testcase_05 AC 133 ms
5,376 KB
testcase_06 AC 114 ms
5,376 KB
testcase_07 AC 106 ms
5,376 KB
testcase_08 AC 107 ms
5,376 KB
testcase_09 AC 180 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,(int)(n)-1,0)
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP(i,0,(int)(n)-1)
#define INF 100000000

typedef long long ll;

const int loops = 100000;

int main() {
    int i, j, n;
    int a[20], b[20];
    double pa, pb, ans;
    cin >> n >> pa >> pb;
    rep (i,n) cin >> a[i];
    rep (i,n) cin >> b[i];
    pa *= 1000; pb *= 1000;
    sort(a,a+n); sort(b,b+n);
    ans = 0;
    rep (i,loops) {
        int p = 0;
        vector<int> va(n), vb(n);
        rep (j,n) {
            va[j] = a[j];
            vb[j] = b[j];
        }
        rep (j,n) {
            int x = rand() % 1000;
            int y = rand() % 1000;
            int ia, ib;
            if (j == n-1 || x < pa)
                ia = 0;
            else
                ia = rand() % (n-j-1) + 1;
            if (j == n-1 || y < pb)
                ib = 0;
            else
                ib = rand() % (n-j-1) + 1;
            if (va[ia] > vb[ib])
                p += va[ia] + vb[ib];
            else if (va[ia] < vb[ib])
                p -= va[ia] + vb[ib];
            va.erase(next(va.begin(),ia));
            vb.erase(next(vb.begin(),ib));
        }
        if (p > 0)
            ans++;
    }
    cout << ans / loops << endl;
    return 0;
}
0