Submission #3286298


Source Code Expand

n = gets.to_i
a = (n.times.map{[gets.to_i,0]}+n.times.map{[gets.to_i,1]}).sort_by{|i,j|i}
ans = 1
mod = 10**9+7
s = [0,0]

for i in 0..2*n-1
  if s[1^a[i][1]] == 0
    s[a[i][1]] += 1
  else
    ans *= s[1^a[i][1]]
    ans %= mod
    s[1^a[i][1]] -= 1
  end
end

puts ans

Submission Info

Submission Time
Task A - 1D Matching
User koikotya
Language Ruby (2.3.3)
Score 500
Code Size 287 Byte
Status AC
Exec Time 375 ms
Memory 23928 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 14
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 224 ms 14456 KB
001.txt AC 82 ms 6648 KB
002.txt AC 111 ms 8312 KB
003.txt AC 126 ms 9080 KB
004.txt AC 333 ms 22776 KB
005.txt AC 372 ms 23928 KB
006.txt AC 375 ms 23928 KB
007.txt AC 372 ms 23928 KB
008.txt AC 372 ms 23928 KB
009.txt AC 372 ms 23928 KB
010.txt AC 361 ms 23928 KB
011.txt AC 371 ms 23928 KB
example0.txt AC 7 ms 1788 KB
example1.txt AC 7 ms 1788 KB