ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1100. Final Standings

Michael WA4, C#, Please help to find a mistake [2] // Problem 1100. Final Standings 17 Oct 2016 22:17
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]);
            }
        }
    }
}
ToadMonster Re: WA4, C#, Please help to find a mistake [1] // Problem 1100. Final Standings 18 Oct 2016 00:40
Looks like you are sorting by M string representation

Try test
3
1 1
2 100
3 2
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.