結果

問題 No.2615 ペアの作り方
ユーザー karashi-0086A2
提出日時 2025-07-15 19:27:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,106 bytes
コンパイル時間 4,177 ms
コンパイル使用メモリ 258,124 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-07-15 19:27:42
合計ジャッジ時間 5,451 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;
using pii = pair<ll, ll>;
using vpii = vector<pii>;
using mint = modint998244353;
// using mint = modint1000000007;
#define endl '\n'
#define rep(i, a) for (ll i = 0; i < a; i++)
#define f(i, a, b) for (ll i = a; i < b; i++)
#define rf(i, a, b) for (ll i = a; i > b; i--)
const ll INF = LLONG_MAX / 4;
void io_setup() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(16);
}

template<typename T>
T fact(int n, bool inv = false) {
    assert(n >= 0);
    static std::vector<std::pair<T, T>> factorials = {{1, 1}};
    for (int i = factorials.size(); i <= n; ++i)
        factorials.emplace_back(i * factorials[i - 1].first, 0);
    if (inv && factorials[n].second == 0) {
        if constexpr (std::is_integral_v<T>)
            factorials[n].second = factorials[n].first <= 1 ? 1 : 0;
#ifdef INCLUDED_ACL
        else if constexpr (atcoder::internal::is_modint<T>::value)
            factorials[n].second = mint_inv(factorials[n].first);
#endif  // INCLUDED_ACLq
        else
            factorials[n].second = 1 / factorials[n].first;
    }
    return inv ? factorials[n].second : factorials[n].first;
}

int main(void) {
    io_setup();
    int n;
    cin >> n;
    vi x(n), y(n);
    rep(i, n) {
        cin >> x[i];
    }
    rep(i, n) {
        cin >> y[i];
    }
    sort(x.begin(), x.end());
    sort(y.rbegin(), y.rend());
    mint ans = 1;
    auto judge = [&](int t) {
        if (x[t] <= y[t]) return 1;
        else return 0;
    };
    int ok = 0, ng = n;
    while (ng - ok > 1) {
        int mid = (ok + ng) / 2;
        if (judge(mid)) ok = mid;
        else ng = mid;
    }
    ok++;
    f(i, 1, ok + 1) {
        ans *= i;
    }
    f(i, 1, n - ok + 1) {
        ans *= i;
    }
    cout << ans.val() << endl;
}
0