Submission #1811352
Source Code Expand
import java.util.Arrays; import java.util.Scanner; class event implements Comparable<event>{ public int a; public int b; public event(int a , int b){ this.a = a; this.b = b; } public int compareTo(event other){ // return b - other.b; return Integer.compare(b , other.b); } } public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int[] size = new int[2]; event[] vs = new event[2*N]; for (int x=0; x<2; x++) for (int i=0; i<N; i++) vs[i+x*N] = new event(x, in.nextInt()); Arrays.sort(vs); long mod = 1_000_000_007; long res = 1L; for (event e : vs) { if (size[1 - e.a] > 0){ res *= size[1 - e.a]; res %= mod; size[1 - e.a]--; } else { size[e.a]++; } } System.out.println(res); } }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | Younes |
Language | Java8 (OpenJDK 1.8.0) |
Score | 500 |
Code Size | 1330 Byte |
Status | AC |
Exec Time | 958 ms |
Memory | 96468 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 | 646 ms | 65272 KB |
001.txt | AC | 409 ms | 41656 KB |
002.txt | AC | 457 ms | 49764 KB |
003.txt | AC | 480 ms | 54636 KB |
004.txt | AC | 765 ms | 72560 KB |
005.txt | AC | 835 ms | 96108 KB |
006.txt | AC | 856 ms | 90636 KB |
007.txt | AC | 835 ms | 95828 KB |
008.txt | AC | 896 ms | 96468 KB |
009.txt | AC | 853 ms | 95716 KB |
010.txt | AC | 958 ms | 92308 KB |
011.txt | AC | 867 ms | 89920 KB |
example0.txt | AC | 99 ms | 23124 KB |
example1.txt | AC | 98 ms | 21844 KB |