Submission #3377688
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 multiplyMemo = 1; 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とすると、改行なしで出力。 } static long DivideMod(long x, long a, long p)//戻り値はx^a(mod p) { long num = 2; long answer = 1; long check = a; long memo = x%p; while(check > 0) { if(check % num == num / 2) { check -= num / 2; answer *= memo; answer %= p; } memo *= memo; memo %= p; num *= 2; } return answer; } static long DivideModReverse(long x, long p)//戻り値はx^-1(mod p), pは素数 { long answer = DivideMod(x, p-2, p); return answer; } }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | suikameron |
Language | C# (Mono 4.6.2.0) |
Score | 500 |
Code Size | 1710 Byte |
Status | AC |
Exec Time | 210 ms |
Memory | 27472 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 | 132 ms | 24536 KB |
001.txt | AC | 59 ms | 13408 KB |
002.txt | AC | 77 ms | 21852 KB |
003.txt | AC | 82 ms | 15712 KB |
004.txt | AC | 183 ms | 22996 KB |
005.txt | AC | 205 ms | 25424 KB |
006.txt | AC | 210 ms | 23376 KB |
007.txt | AC | 205 ms | 25424 KB |
008.txt | AC | 208 ms | 27472 KB |
009.txt | AC | 210 ms | 23504 KB |
010.txt | AC | 204 ms | 23376 KB |
011.txt | AC | 206 ms | 25424 KB |
example0.txt | AC | 22 ms | 11220 KB |
example1.txt | AC | 21 ms | 11220 KB |