Time limit: 0.4s
Memory limit: 256M
Brute Force Practice 1 — Hard Version
You have a list of unique numbers each no larger than . The size of the list is no greater than . You perform the following operation on the list repeatedly: take the minimum of the numbers, and remove it from the list. You stop when the list is empty.
In what order are the numbers removed?
The first line will have the size of the list.
Each line after that will be an element of the list. You are guaranteed no two elements are the same.
Print one line for each time the operation was performed: the number that was removed at that step.
3 5 8 2
2 5 8
I submitted a solution in java a TLE'd then did the same code in c++ and AC'd.
Wait, is this not the same problem as List Minimum (https://dmoj.ca/problem/bf1)? The instructions are worded differently, but the problem seems the same. I even used the same code for both. Could someone explain this?
Yeah, he’s right.
My code for List Minimum is the same as the List Minimum (Hard)
This is rather random, given that the AC is smaller by at least 20%
The constraints of the problems are different. The ones in this problem are a lot larger than the other one, so some solutions (not yours apparently) that may AC the other one may fail this one.
Ah, that clears things up, Thank you!
Could anyone help me out? When I run my code on eclipse oxygen it works fine but when I submit it says invalid return and java.lang.NullPointerException
EDIT: I fixed the issue, still not quite sure what caused it. However, even while using BufferedReader the last case is still giving me TLE, not sure what I can do about that...
Reading the tips section at https://dmoj.ca/tips/ may provide some hints. (It's not reading the input that's causing the TLE).
To deal with input/output, you may want to add this to your program:
(void (map displayln (my-sort (build-list (read) (lambda (x) (read))) <)))
For Java users getting TLE on the last case, reading this might be helpful.
Thx a lot