Submission #3377695
Source Code Expand
using System; using System.Linq;//リストの使用 using System.Collections.Generic; class Program { static void Main() { long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。 long[][] nums = new long[2*n][];//座標と種類 long memo = 0; long answer = 1; long mod = 1000000007; for(long i = 0; i < n; i++) { nums[i] = new long[2]; nums[i][0] = long.Parse(Console.ReadLine()); nums[i][1] = 0; } for(long i = n; i < 2*n; i++) { nums[i] = new long[2]; nums[i][0] = long.Parse(Console.ReadLine()); nums[i][1] = 1; } Array.Sort(nums, (a, b) => a[0].CompareTo(b[0])); for(long i = 0; i < 2*n; i++) { if(nums[i][1] == 0) { memo++; if(memo > 1) answer *= Math.Abs(memo); answer %= mod; } else { memo--; if(memo < -1) answer *= Math.Abs(memo); answer %= mod; } //Console.WriteLine(answer); } Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。 } }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | suikameron |
Language | C# (Mono 4.6.2.0) |
Score | 500 |
Code Size | 1151 Byte |
Status | AC |
Exec Time | 215 ms |
Memory | 25424 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 | 129 ms | 20440 KB |
001.txt | AC | 56 ms | 13408 KB |
002.txt | AC | 75 ms | 19804 KB |
003.txt | AC | 81 ms | 17760 KB |
004.txt | AC | 183 ms | 22996 KB |
005.txt | AC | 215 ms | 25424 KB |
006.txt | AC | 214 ms | 23376 KB |
007.txt | AC | 209 ms | 23376 KB |
008.txt | AC | 206 ms | 25424 KB |
009.txt | AC | 206 ms | 25424 KB |
010.txt | AC | 208 ms | 25424 KB |
011.txt | AC | 205 ms | 25424 KB |
example0.txt | AC | 21 ms | 11220 KB |
example1.txt | AC | 21 ms | 11220 KB |