Submission #3377516
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; 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)-1; } else { memo--; if(memo < -1) answer += Math.Abs(memo)-1; } } Console.WriteLine(answer);//WriteLineをWriteとすると、改行なしで出力。 } }
Submission Info
Submission Time | |
---|---|
Task | A - 1D Matching |
User | suikameron |
Language | C# (Mono 4.6.2.0) |
Score | 0 |
Code Size | 1039 Byte |
Status | WA |
Exec Time | 216 ms |
Memory | 27472 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 147 ms | 20440 KB |
001.txt | WA | 56 ms | 13408 KB |
002.txt | WA | 75 ms | 17756 KB |
003.txt | WA | 80 ms | 17760 KB |
004.txt | WA | 181 ms | 22996 KB |
005.txt | WA | 203 ms | 23376 KB |
006.txt | WA | 204 ms | 27472 KB |
007.txt | WA | 205 ms | 25424 KB |
008.txt | WA | 205 ms | 25424 KB |
009.txt | WA | 216 ms | 23376 KB |
010.txt | WA | 199 ms | 25424 KB |
011.txt | AC | 207 ms | 27472 KB |
example0.txt | AC | 21 ms | 9172 KB |
example1.txt | AC | 21 ms | 9172 KB |