結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,248 KB
testcase_01 AC 32 ms
5,376 KB
testcase_02 AC 202 ms
5,376 KB
testcase_03 AC 209 ms
5,376 KB
testcase_04 AC 198 ms
5,376 KB
testcase_05 AC 182 ms
5,376 KB
testcase_06 AC 165 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 226 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 = 150000;

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 = (x-pa) * (n-j-1) / (1000 - pa) + 1;
            if (j == n-1 || y < pb)
                ib = 0;
            else
                ib = (y-pb) * (n-j-1) / (1000 - pb) + 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