結果

問題 No.2615 ペアの作り方
ユーザー Yaowei LyuYaowei Lyu
提出日時 2024-01-26 21:34:38
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 5,680 ms
コンパイル使用メモリ 320,220 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-26 21:34:48
合計ジャッジ時間 7,054 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 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 46 ms
6,676 KB
testcase_16 AC 46 ms
6,676 KB
testcase_17 AC 46 ms
6,676 KB
testcase_18 AC 46 ms
6,676 KB
testcase_19 AC 45 ms
6,676 KB
testcase_20 AC 45 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include <atcoder/all>

#ifndef ONLINE_JUDGE
#include "debug.h"  // https://github.com/Heltion/debug.h/blob/main/debug.h
#else
#define debug(...) (void)417
#endif

using i64 = int64_t;
using mint = atcoder::modint998244353;
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int& xi : x) { cin >> xi; }
  for (int& yi : y) { cin >> yi; }
  ranges::sort(x);
  ranges::sort(y, greater());
  vector<int> a, b, c, d;
  for (int i = 0; i < n; i += 1) {
    if (x[i] < y[i]) {
      a.push_back(x[i]);
      b.push_back(y[i]);
    } else {
      c.push_back(x[i]);
      d.push_back(y[i]);
    }
  }
  auto f = [&](vector<int> a, vector<int> b) {
    mint res = 1;
    ranges::sort(a);
    ranges::sort(b);
    for (int i = 0, j = 0; i < ssize(b); i += 1) {
      while (j < ssize(a) and a[j] < b[i]) { j += 1; }
      res *= j - i;
    }
    return res;
  };
  cout << (f(a, b) * f(d, c)).val();
}
0