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 1510. Order

MLE #21
Posted by Maxm 26 Mar 2017 19:53
I don't understand. I use quicksort and then find solution very fast. MLE #21 say me that
memory limit! I use c#.

Edited by author 26.03.2017 21:16

Edited by author 26.03.2017 21:16

Edited by author 26.03.2017 21:17

Edited by author 26.03.2017 21:37
Re: WA #21
Posted by Maxm 26 Mar 2017 20:49
AND i use List
Re: WA #21
Posted by ToadMonster 26 Mar 2017 22:44
MLE - your program spent too much memory. No perfomance problem detected.

Looks like you read all N inputs into list.
Try using dictionary K -> count.
Re: WA #21
Posted by Maxm 27 Mar 2017 11:54
I use Dictionary and get MLE too. I think problem in input data. I enter input data like:

string[] input =  Console.In.ReadToEnd().Split(
                     new char[] { ' ', '\t', '\n', '\r' },
                     StringSplitOptions.RemoveEmptyEntries);



And add in dictionary

for (int i = 0; i < input.Length; i++){
   ...
}

I don't understand what's wrong :(
Re: WA #21
Posted by ToadMonster 27 Mar 2017 18:18
Was wrong.
Dictionary => TLE.
Got input into List, sorted List, took middle one => AC.

Just avoid reading whole input. Use something like
static int readInt() {
    return Int.Parse(Console.ReadLine());
}
Re: WA #21
Posted by Maxm 27 Mar 2017 21:33
Thanks! I read data like:

static int readInt() {
    return Int.Parse(Console.ReadLine());
}

But ... I have WA #25..