Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created June 3, 2021 01:00
Show Gist options
  • Save sakapon/020f3f8c35a09e2631fc86829dc2435d to your computer and use it in GitHub Desktop.
Save sakapon/020f3f8c35a09e2631fc86829dc2435d to your computer and use it in GitHub Desktop.
競プロ典型 90 問 / Q048
using System;
using System.Linq;
class Q048
{
static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
static long[] ReadL() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
static void Main()
{
var (n, k) = Read2();
Console.WriteLine(new bool[n].Select(_ => ReadL()).SelectMany(p => new[] { p[0] - p[1], p[1] }).OrderByDescending(x => x).Take(k).Sum());
}
}
@sakapon
Copy link
Author

sakapon commented Jun 3, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment