The following code works fine on my local machine as well the code jam editor. However, as soon as I submit it gives me run time error. Any idea whats going wrong?? Before that a few important points - the reason I am not using <dict_name>.values() is because Python dictionaries may randomly change the order of elements during compile or run time. I figured that out when it was working on my local machine but giving wrong answers in the code jam editor. However, after making these changes the sample tests were running fine. However, once submitted it is always showing RE and the second test set skipped obviously. This is my approach 1. sort jobs according to start time 2. initialize end times of Cameron and Jamie to 0 and 0 indicating they aren’t busy 3. Take one job from the sorted array and compare its start time with the end time allocated to the boy, if it is less than that then i.e. he is busy. Do a similar check for the girl. Even if she is busy then you can declare it as “impossible”. 4. If they are not the job is allocated to the concerned partner (boy or the girl) and the same is marked in the original input (i.e. the allocation ‘J’ or ‘C’). The end time of that partner is now updated to the end time of the job they have been just allocated. 5. Keep enumerating through the sorted array until you have allocated all jobs or have declared the scheduling impossible. 6. At the end concatenate the letters (in order) from step 4 corresponding to the actual input which will be the final solution.
T = int(input()) for i in range(1,T+1): N=int(input()) jobs={} for x in range(N): jobs[tuple(map(int, input().split(' ')))]= x L = [0]*N cj=[0,0] m = sorted(jobs.keys()) imp = False for j in m: if j[0] >= cj[0]: L[jobs[j]] = 'C' cj[0] = j[1] elif j[0] >= cj[1]: L[jobs[j]] = 'J' cj[1] = j[1] else: imp = True break if imp==True: print("Case #{}: IMPOSSIBLE".format(i)) else: print("Case #{}: {}".format(i,''.join(L))) -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/386a4afe-a270-4e61-a4b6-e4b89a3450e1%40googlegroups.com.