Submission #4069961
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; while(left<n){ if(a[left]>b[left]){ int[] c = b; b = a; a = c; } int right = left+1; while(right<n&&a[right]<b[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 | 991 Byte |
Status | WA |
Exec Time | 671 ms |
Memory | 88008 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 | 546 ms | 62940 KB |
001.txt | WA | 379 ms | 46460 KB |
002.txt | WA | 424 ms | 44240 KB |
003.txt | WA | 442 ms | 44756 KB |
004.txt | WA | 614 ms | 64600 KB |
005.txt | WA | 658 ms | 62612 KB |
006.txt | WA | 611 ms | 62548 KB |
007.txt | WA | 665 ms | 88008 KB |
008.txt | WA | 640 ms | 63320 KB |
009.txt | WA | 618 ms | 86680 KB |
010.txt | AC | 671 ms | 62308 KB |
011.txt | AC | 663 ms | 62828 KB |
example0.txt | AC | 98 ms | 21588 KB |
example1.txt | AC | 98 ms | 19412 KB |