結果

問題 No.133 カードゲーム
ユーザー miuraKRmiuraKR
提出日時 2019-11-10 18:08:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,834 bytes
コンパイル時間 2,072 ms
コンパイル使用メモリ 203,580 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 07:49:31
合計ジャッジ時間 3,235 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少.
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

int main() {
cin.tie(0);
ios::sync_with_stdio(false);

double N; cin >> N;
VI A(N), B(N); 
rep(i, 0, N) cin >> A[i];
rep(i, 0, N) cin >> B[i];
sort(ALL(A));
sort(ALL(B));
int reno = 0, winAgame= 0;

do{
    do{
        int winAcard = 0;
        ++reno;
        rep(i, 0, N) if (A[i] > B[i]) ++winAcard;
        if (winAcard > N/2) ++winAgame;
    }while(next_permutation(ALL(B)));
}while(next_permutation(ALL(A)));
cout << winAgame / (double)reno << "\n";
}

// 境界,出力文字列 チェック
// 可読性優先.高速化次点.
// まずは全探索,分割統治,次にDP
// 制限を見る
// 偶奇,逆から,ソート,出現回数,出現位置,DP, 余事象,包除
// データ構造. 問題の特徴量
// 存在判定:構成方法,入力の特徴
// gcd, lcm ,素因数分解.
// 例外を十分に含む一般化.想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい.各場合を確実に対処.
// 自明な例から処理,除外.
// 小数のときは,精度の設定する.doubel 変数に数値を入力するときは 123. とする.
// テストケース作成は数表あり

0