Hackerrank - Greedy - Jim and the Orders
Jim's Burgers has n hungry burger fans waiting in line. Each unique order,i, is placed by a customer at time ti, and the order takes di units of time to process.
Given the information for all n orders, can you find and print the order in which all n customers will receive their burgers? If two or more orders are fulfilled at the exact same time t, sort them by ascending order number.
Sample Input 0
3
1 3
2 3
3 3
Sample Output 0
1 2 3
Sample Input 1
5
8 1
4 2
5 6
3 1
4 3
Sample Output 1
4 2 5 1 3
Given the information for all n orders, can you find and print the order in which all n customers will receive their burgers? If two or more orders are fulfilled at the exact same time t, sort them by ascending order number.
Sample Input 0
3
1 3
2 3
3 3
Sample Output 0
1 2 3
Sample Input 1
5
8 1
4 2
5 6
3 1
4 3
Sample Output 1
4 2 5 1 3
Solutionitt = int(raw_input()) dict = {} for k in range(1,itt+1): dict[k] = sum(map(int, raw_input().split())) new_dict = sorted(dict, key=dict.get) print " ".join(map(str,new_dict))
Comments
Post a Comment