Skip to content

Instantly share code, notes, and snippets.

@sakapon
Last active December 15, 2019 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakapon/ee5d8b247c56e101ab931ab3d2899d04 to your computer and use it in GitHub Desktop.
Save sakapon/ee5d8b247c56e101ab931ab3d2899d04 to your computer and use it in GitHub Desktop.
sumitrust2019 D - Lucky PIN (3)
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