Submission #1834590
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 = 1e9 + 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 | 500 |
Code Size | 706 Byte |
Status | AC |
Exec Time | 277 ms |
Memory | 59212 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
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 | AC | 187 ms | 33964 KB |
001.txt | AC | 97 ms | 16832 KB |
002.txt | AC | 116 ms | 27840 KB |
003.txt | AC | 120 ms | 28096 KB |
004.txt | AC | 261 ms | 57968 KB |
005.txt | AC | 273 ms | 59212 KB |
006.txt | AC | 277 ms | 59212 KB |
007.txt | AC | 269 ms | 59212 KB |
008.txt | AC | 275 ms | 59212 KB |
009.txt | AC | 274 ms | 59212 KB |
010.txt | AC | 261 ms | 59212 KB |
011.txt | AC | 271 ms | 59212 KB |
example0.txt | AC | 54 ms | 7372 KB |
example1.txt | AC | 54 ms | 7372 KB |