-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20-1.linq
35 lines (32 loc) · 969 Bytes
/
20-1.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<Query Kind="Program">
<Namespace>System.Security.Cryptography</Namespace>
</Query>
void Main()
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(Util.CurrentQueryPath));
string[] inputLines = File.ReadAllLines("20.txt");
Dictionary<ulong, ulong> ranges = new Dictionary<ulong, ulong>();
foreach (var il in inputLines)
{
ulong[] split = il.Split('-').Select(l => ulong.Parse(l)).ToArray();
if (ranges.ContainsKey(split[0]))
{
if (ranges[split[0]] < split[1]) ranges[split[0]] = split[1];
}
else ranges.Add(split[0], split[1]);
}
ulong min = 0;
while (true)
{
if (ranges.Keys.Min() <= min)
{
if (min <= ranges[ranges.Keys.Min()]) min = ranges[ranges.Keys.Min()] + 1;
ranges.Remove(ranges.Keys.Min());
}
else
{
min.Dump();
return;
}
}
}