結果

問題 No.2615 ペアの作り方
ユーザー ococonomy1
提出日時 2024-01-26 21:29:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 2,151 bytes
コンパイル時間 1,210 ms
コンパイル使用メモリ 114,800 KB
最終ジャッジ日時 2025-02-18 22:57:08
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
// #define AMARI 1000000007
#define TIME_LIMIT 1980000
#define el '\n'
#define El '\n'
#define MULTI_TEST_CASE false
void solve(void) {
//
//
//
int n;
cin >> n;
vector<int> x(n),y(n);
for(int i = 0; i < n; i++)cin >> x[i];
for(int i = 0; i < n; i++)cin >> y[i];
if(*max_element(x.begin(),x.end()) < *min_element(y.begin(),y.end()) || *min_element(x.begin(),x.end()) > *max_element(y.begin(),y.end())){
ll ans = 1;
for(int i = 1; i <= n; i++){
ans *= (ll)i; ans %= AMARI;
}
cout << ans << el;
return;
}
sort(x.begin(),x.end());
sort(y.rbegin(),y.rend());
int cnt = 0;
for(int i = 0; i < n; i++){
if(x[i] < y[i])cnt++;
}
//cerr << El;
ll ans = 1;
for(int i = 1; i <= cnt; i++){
ans *= (ll)i; ans %= AMARI;
}
for(int i = 1; i <= n - cnt; i++){
ans *= (ll)i; ans %= AMARI;
}
cout << ans << el;
return;
}
void calc(void) {
return;
}
signed main(void) {
cin.tie(nullptr);
ios::sync_with_stdio(false);
calc();
int t = 1;
if(MULTI_TEST_CASE) cin >> t;
while(t--) {
solve();
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0