結果

問題 No.133 カードゲーム
コンテスト
ユーザー 小畑裕貴
提出日時 2026-01-29 13:13:31
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 875 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 911 ms
コンパイル使用メモリ 132,984 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2026-01-29 13:13:33
合計ジャッジ時間 1,811 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;


int main() {
    int n, score1, score2, ans1 = 0, ans2 = 0;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<int> ind(n);
    iota(ind.begin(), ind.end(), 0);
    do {
        score1 = 0;
        score2 = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] > b[ind[i]]) score1++;
            else if (a[i] < b[ind[i]]) score2++;
        }
        if (score1 > score2) ans1++;
        else ans2++;
    } while (next_permutation(ind.begin(), ind.end()));
    cout << (double)ans1 / (ans1+ans2) << endl;
}
0