Submission #1834555


Source Code Expand

import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const n = +input[0];

type Obj = { side: number, pos: number };
const a: Obj[] = [];
for (let i = 0; i < n; i++) {
	a.push({side: 0, pos: +input[i + 1]});
}

for (let i = 0; i < n; i++) {
	a.push({side: 1, pos: +input[i + n + 1]});
}

a.sort((a: Obj, b: Obj) => {
	return a.pos - b.pos;
});

const MOD = 10e9 + 7;
let stack = 0;
let side = -1;
let result = 1;
for (const obj of a) {
	if (stack === 0) {
		stack++;
		side = obj.side;
	}
	else if (obj.side === side) {
		stack++;
	}
	else {
		result *= stack;
		result %= MOD;
		stack -= 1;
	}
}

console.log(result);

Submission Info

Submission Time
Task A - 1D Matching
User tatamo
Language TypeScript (2.1.6)
Score 0
Code Size 707 Byte
Status WA
Exec Time 266 ms
Memory 59212 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 3
WA × 11
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 WA 181 ms 33964 KB
001.txt WA 95 ms 16832 KB
002.txt WA 113 ms 27840 KB
003.txt WA 117 ms 28096 KB
004.txt WA 245 ms 57968 KB
005.txt WA 265 ms 59212 KB
006.txt WA 266 ms 59212 KB
007.txt WA 261 ms 59212 KB
008.txt WA 261 ms 59212 KB
009.txt WA 266 ms 59212 KB
010.txt WA 248 ms 59212 KB
011.txt AC 261 ms 59212 KB
example0.txt AC 53 ms 7372 KB
example1.txt AC 53 ms 7372 KB