Submission #1955526


Source Code Expand

package tester;

import java.util.Arrays;
import java.util.Scanner;

class Main {
	int n;
	int[] a;
	int[] b;
	final long MOD = 1_000_000_000 + 7;

	void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new int[n];
		b = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; ++i) {
			b[i] = sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		long[] c = new long[2 * n];
		for (int i = 0; i < n; ++i) {
			c[2 * i] = 2 * a[i];
			c[2 * i + 1] = 2 * b[i] + 1;
		}
		Arrays.sort(c);
		int out = 0, in = 0;
		long ans = 1;
		for (int i = 0; i < 2 * n; ++i) {
			if (c[i] % 2 == 1) {// outlet
				++out;
			} else {// pc
				++in;
			}
			while (out > 0 && in > 0) {
				ans = ans * Math.max(out, in);
				--out;
				--in;
			}
		}
		if (out != 0 || in != 0)
			throw new AssertionError();
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Submission Info

Submission Time
Task A - 1D Matching
User fortoobye
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 1097 Byte
Status RE
Exec Time 81 ms
Memory 23508 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
RE × 2
RE × 14
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt RE 81 ms 21460 KB
001.txt RE 76 ms 19412 KB
002.txt RE 77 ms 19668 KB
003.txt RE 80 ms 22612 KB
004.txt RE 79 ms 20564 KB
005.txt RE 79 ms 23252 KB
006.txt RE 77 ms 18772 KB
007.txt RE 77 ms 19796 KB
008.txt RE 78 ms 20052 KB
009.txt RE 77 ms 17872 KB
010.txt RE 79 ms 23508 KB
011.txt RE 77 ms 20692 KB
example0.txt RE 77 ms 20052 KB
example1.txt RE 77 ms 21460 KB