|
|
вернуться в форумWA4, C#, Please help to find a mistake I use LINQ to sort this sequence, it works pretty well on all tests i found. Any ideas why it works wrong on test 4? using System; using System.Linq; namespace Таблица_результатов { class Program {
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); string[] lines = new string[n]; for (int i = 0; i < n; i++) { lines[i] = Console.ReadLine(); }
var a = lines .Select(x => x.Split()) .ToArray() .OrderByDescending(x => x[1]);
foreach (var x in a) { Console.WriteLine(x[0] + " " + x[1]); } } } } Re: WA4, C#, Please help to find a mistake Looks like you are sorting by M string representation Try test 3 1 1 2 100 3 2 Re: WA4, C#, Please help to find a mistake Yeah, you are right, thanks for answering, now it passes the test. P.S. Fixed by replacing .OrderByDescending argument with (x => int.Parse(x[1])) if someone's interested. |
|
|