Submission #1986285
Source Code Expand
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ long mod = (long) 1e9 + 7; long[] frac = new long[N+1]; frac[0] = 1; for(int i=1;i<=N;i++) frac[i] = (frac[i-1] * i) % mod; List<Pair> L = new List<Pair>(); for(int i=0;i<N;i++){ L.Add(new Pair(A[i], 1)); } for(int i=0;i<N;i++){ L.Add(new Pair(B[i], -1)); } L.Sort((p, q) => p.Val.CompareTo(q.Val)); long ans = 1; long tot = 0; long sig = 0; foreach(var p in L){ sig += p.Sig; tot ++; if(sig == 0){ ans *= frac[tot / 2]; ans %= mod; tot = 0; } } Console.WriteLine(ans); } class Pair{ public int Val, Sig; public Pair(int val, int sig){ Val = val; Sig = sig; } } int N; int[] A,B; public Sol(){ N = ri(); A = new int[N]; for(int i=0;i<N;i++) A[i] = ri(); B = new int[N]; for(int i=0;i<N;i++) B[i] = ri(); } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);} static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));} static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));} static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));} }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | kuuso |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 1740 Byte |
Status | WA |
Exec Time | 293 ms |
Memory | 28372 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 159 ms | 18012 KB |
001.txt | WA | 69 ms | 14432 KB |
002.txt | WA | 95 ms | 12512 KB |
003.txt | WA | 102 ms | 20444 KB |
004.txt | WA | 231 ms | 19288 KB |
005.txt | WA | 289 ms | 22228 KB |
006.txt | WA | 268 ms | 28372 KB |
007.txt | WA | 268 ms | 24276 KB |
008.txt | WA | 293 ms | 24276 KB |
009.txt | WA | 287 ms | 24276 KB |
010.txt | AC | 269 ms | 24148 KB |
011.txt | AC | 271 ms | 24276 KB |
example0.txt | AC | 22 ms | 11220 KB |
example1.txt | AC | 22 ms | 13268 KB |