結果
問題 | No.2615 ペアの作り方 |
ユーザー | tenten |
提出日時 | 2024-01-29 19:03:30 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 521 ms / 2,000 ms |
コード長 | 2,056 bytes |
コンパイル時間 | 2,807 ms |
コンパイル使用メモリ | 90,832 KB |
実行使用メモリ | 69,036 KB |
最終ジャッジ日時 | 2024-01-29 19:03:38 |
合計ジャッジ時間 | 8,058 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
54,112 KB |
testcase_01 | AC | 54 ms
54,128 KB |
testcase_02 | AC | 54 ms
54,028 KB |
testcase_03 | AC | 54 ms
54,228 KB |
testcase_04 | AC | 53 ms
54,104 KB |
testcase_05 | AC | 53 ms
54,112 KB |
testcase_06 | AC | 54 ms
54,112 KB |
testcase_07 | AC | 55 ms
54,128 KB |
testcase_08 | AC | 54 ms
54,116 KB |
testcase_09 | AC | 92 ms
55,000 KB |
testcase_10 | AC | 91 ms
55,272 KB |
testcase_11 | AC | 82 ms
55,264 KB |
testcase_12 | AC | 83 ms
55,000 KB |
testcase_13 | AC | 92 ms
55,144 KB |
testcase_14 | AC | 83 ms
55,136 KB |
testcase_15 | AC | 521 ms
68,648 KB |
testcase_16 | AC | 446 ms
68,656 KB |
testcase_17 | AC | 491 ms
69,036 KB |
testcase_18 | AC | 477 ms
68,956 KB |
testcase_19 | AC | 443 ms
68,652 KB |
testcase_20 | AC | 482 ms
66,732 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) { Scanner sc = new Scanner(); int n = sc.nextInt(); PriorityQueue<Long> queue = new PriorityQueue<>(); for (int i = 0; i < n; i++) { queue.add(sc.nextLong() * 2); } for (int i = 0; i < n; i++) { queue.add(sc.nextLong() * 2 + 1); } long count = 0; for (int i = 0; i < n; i++) { count += queue.poll() % 2; } System.out.println(fact(count) * fact(n - count) % MOD); } static long fact(long x) { long ans = 1; for (int i = 1; i <= x; i++) { ans *= i; ans %= MOD; } return ans; } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }