結果

問題 No.2615 ペアの作り方
ユーザー Dec0DeddDec0Dedd
提出日時 2024-01-26 21:28:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 171,812 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-26 21:28:33
合計ジャッジ時間 3,359 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5+10;
const int MOD = 998244353;

int a[N], b[N], n;

ll fac(ll n) {
    if (n == 0) return 1;
    return (n*fac(n-1))%MOD;
}

void solve() {
    cin>>n;
    for (int i=1; i<=n; ++i) cin>>a[i];
    for (int i=1; i<=n; ++i) cin>>b[i];
    sort(a+1, a+n+1), sort(b+1, b+n+1, greater<int>());

    for (int i=1; i<=n; ++i) {
        if (b[i] < a[i]) {
            cout<<(fac(i-1)*fac(n-i+1))%MOD<<"\n";
            return;
        }
    }

    cout<<fac(n)<<"\n";
}

int main() {
    int t=1; //cin>>t;
    while (t--) solve();
}
0