I just wish I had thought of this during the test. I manually tested in on the test cases and it passed all with the longest one taking about 0.45 seconds.
My solution for Wealth Disparity is working in all the test cases except for this one
Subtask 2
Outcome Details Execution time Memory used
Not correct Execution timed out (wall clock limit exceeded) 0.992 s 896 KiB
It is executing in less than 1 second. So, shouldnāt it work? Also, I think that changing the time limit from 3s to 1s in the re-evaluation is unfair.
EDIT:
I mailed [email protected] regarding this. This is what I was mailed back in return:
āYes, it was 3 seconds on the iON server and is 1 second on the ICO
server, but this does not matter. We checked your code manually.
Your algorithm is O(n^2) and the problem requires an O(n) solution.
The case where you get time limit exceeded is the one large test case
that is there to check for O(n^2) vs O(n). The server sometimes
reports an inaccurate time when the time limit is reached, but the
verdict in this case is definitely correct.ā
I understand what they are trying to say, but if they allowed the cpu time complexity to be less than 3 seconds on the iON server, then shouldnāt they allow it in the re-evaluation as well?
I donāt get the logic to define a well bracket sequence:
i 1 2 3 4 5 6
V[i] 4 5 -2 1 1 6
B[i] 1 3 4 2 5 6
It says that the items a pos (1 3) is a well bracket sequence. (also if there is an open bracket not closed inside it)
than says (1 3 4 5) is a well bracket sequence, but these are contiguous and not one inside the other.
At this point I have two doubts:
If I find a sequence (1 1 4) can 4 close 1 either 2 or can close only the second 1.
If I find a sequence (1 4 3 2 5) (k=3) is (1 4 2 5) a well bracket sequence?
Excuse me if I put another post, but the comments doesnāt format properly the code and can be very hard to read. (I cannot ask by myself since I have not enough karma)
Ever about brackets problem. My if to recognize if are valid sequence is the follow:
where pairs is an array 3*n contained all the valid pairs of brackets sequence found. Pairs[0] is the position of the open bracket, pairs[1] is the closed bracket, and pairs[2] is the sum of the pair.
Does somebody tell me if I understood it right?