結果
問題 | No.2615 ペアの作り方 |
ユーザー |
|
提出日時 | 2024-01-26 21:42:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 793 bytes |
コンパイル時間 | 1,755 ms |
コンパイル使用メモリ | 176,200 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-28 07:55:35 |
合計ジャッジ時間 | 2,953 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#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;}