結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 3 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 42 ms
6,676 KB
testcase_16 AC 42 ms
6,676 KB
testcase_17 AC 42 ms
6,676 KB
testcase_18 AC 42 ms
6,676 KB
testcase_19 AC 42 ms
6,676 KB
testcase_20 AC 42 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	cout.tie(NULL);
    int MAX = 1e5, MOD = 998244353;
	vector <long long> factorial(MAX + 1, 1);
    for (int i = 2; i <= MAX; i++)
        factorial[i] = (factorial[i - 1] * i) % MOD;
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater <int> ());
    int numSmallerOrEqual = 0, numGreater = 0;
    for (int i = 0; i < n; i++) {
        numSmallerOrEqual += (a[i] <= b[i]);
        numGreater += (a[i] > b[i]);
    }
    cout << (factorial[numSmallerOrEqual] * factorial[numGreater]) % MOD;
	return 0;
}
0