Submission #4070191
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[][] dic = new int[2*n][]; for(int i=0;i<n;i++){ int a = sc.nextInt(); dic[i] = new int[]{a,0}; } for(int i=n;i<2*n;i++){ int b = sc.nextInt(); dic[i] = new int[]{b,1}; } Arrays.sort(dic,new myc()); long ans = 1; int[] cnt = new int[2]; for(int i=0;i<2*n;i++){ int now = dic[i][1]; if(cnt[1-now]>0){ ans = ans*cnt[1-now]%mod; cnt[1-now]--; }else{ cnt[now]++; } } System.out.println(ans); } static class myc implements Comparator<int[]>{ public int compare(int[] a, int[] b){ return a[0]-b[0]; } } }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | AlbertZ |
Language | Java8 (OpenJDK 1.8.0) |
Score | 500 |
Code Size | 1078 Byte |
Status | AC |
Exec Time | 825 ms |
Memory | 95280 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 | 623 ms | 62328 KB |
001.txt | AC | 399 ms | 46784 KB |
002.txt | AC | 493 ms | 50284 KB |
003.txt | AC | 482 ms | 56684 KB |
004.txt | AC | 800 ms | 77928 KB |
005.txt | AC | 800 ms | 94512 KB |
006.txt | AC | 801 ms | 93960 KB |
007.txt | AC | 763 ms | 93728 KB |
008.txt | AC | 825 ms | 88848 KB |
009.txt | AC | 821 ms | 88532 KB |
010.txt | AC | 814 ms | 90888 KB |
011.txt | AC | 778 ms | 95280 KB |
example0.txt | AC | 97 ms | 21844 KB |
example1.txt | AC | 99 ms | 19668 KB |