-
-
Save sakapon/ee5d8b247c56e101ab931ab3d2899d04 to your computer and use it in GitHub Desktop.
sumitrust2019 D - Lucky PIN (3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
class D | |
{ | |
static void Main() | |
{ | |
Console.ReadLine(); | |
var d = Console.ReadLine().Select((c, i) => new { c, i }).ToLookup(_ => _.c, _ => _.i); | |
var q = from i1 in d.Select(g => g.First()) | |
from i2 in d.Select(g => g.FirstOrDefault(x => x > i1)).Where(x => x > 0) | |
select d.Count(g => g.Last() > i2); | |
Console.WriteLine(q.Sum()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment