Submission #4069990
Source Code Expand
import java.util.*; import java.io.*; import static java.lang.System.in; public class Main { public static void main(String[] args)throws IOException{ Scanner sc = new Scanner(System.in); long mod = 1000000000+7; int n = sc.nextInt(); int[] 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[] fac = new long[n+1]; fac[0]=1; for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod; long ans = 1; int left = 0; int[] base,target; while(left<n){ if(a[left]>b[left]){ base = b; target = a; } else{ base = a; target = b; } int right = left+1; while(right<n&&base[right]<target[left]) right++; ans = ans*fac[right-left]%mod; left = right; } System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | AlbertZ |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 1082 Byte |
Status | WA |
Exec Time | 676 ms |
Memory | 90016 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 | 550 ms | 62616 KB |
001.txt | WA | 353 ms | 46148 KB |
002.txt | WA | 411 ms | 46192 KB |
003.txt | WA | 434 ms | 44520 KB |
004.txt | WA | 623 ms | 63380 KB |
005.txt | WA | 651 ms | 85092 KB |
006.txt | WA | 642 ms | 88800 KB |
007.txt | WA | 676 ms | 85736 KB |
008.txt | WA | 676 ms | 82064 KB |
009.txt | WA | 616 ms | 64492 KB |
010.txt | AC | 654 ms | 90016 KB |
011.txt | AC | 646 ms | 64756 KB |
example0.txt | AC | 96 ms | 21332 KB |
example1.txt | AC | 94 ms | 18644 KB |