結果

問題 No.2615 ペアの作り方
ユーザー kokoseikokosei
提出日時 2024-01-27 09:03:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 862 bytes
コンパイル時間 3,783 ms
コンパイル使用メモリ 255,632 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-27 09:03:54
合計ジャッジ時間 5,568 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
const int mod = 998244353;

int N;
mint ff[101010], fi[101010];
void solve(){
    cin >> N;
    vector<pair<int, int>> a;
    for(int i = 0;i < N;i++){
        int x; cin >> x;
        a.push_back({x, 0});
    }
    for(int i = 0;i < N;i++){
        int y; cin >> y;
        a.push_back({y, 1});
    }
    sort(a.begin(), a.end(), greater<pair<int, int>> {});
    int cnt[2] = {};
    for(int i = 0;i < N;i++){
        cnt[a[i].second]++;
    }
    cout << (ff[cnt[0]] * ff[cnt[1]]).val() << endl;
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ff[0] = fi[0] = 1;
    for(int i = 1;i <= 100000;i++){
        ff[i] = ff[i - 1] * i;
        fi[i] = ff[i].inv();
    }
    solve();
    return 0;
}
0