Did you know that the critically acclaimed MMORPG Final Fantasy XIV has a free trial and includes the entirety of A Realm Reborn AND the award-winning Heavensward expansion up to level 60 with no restrictions on playtime? Sign up, and enjoy Eorzea today! Despite the critical acclaim, however, one disadvantage for people without friends is that they have to resort to the duty finder to do co-op duties, which are required for the main scenario quest. To simplify this scenario, assume that for each possible duty, we know exactly two values to the most precise degree: the time W; it will take to find a party of other players for the duty and C; the time it will take to complete the duty successfully. All time is in seconds. You have exactly T minutes before your next class, and you wish to complete as many duties as possible. You also do not want to repeat any duties you have completed in this period. Can you identify the set of duties to queue for and to complete? Input Format Each test case begins with two space-separated integers N and T, indicating the number of available duties and the time (in minutes) you will have to complete as many duties as possible. 2N lines follow. The first line contains the name of the duty, which may consist of any ASCII values that can be shown on the screen. The second line contains two space-separated integers W; and C₁, indicating the duty's waiting time and completion time (in seconds). Constraints 1≤N≤ 2.105 1 ≤ T, W₁, C₁ ≤ 10⁹
Information is present in the screenshot and below. Based on that need help in solving the code for this problem in python. The time complexity has to be as less as possible (nlogn or n at best, no n^2). Apply greedy
Output Format
Output a single integer indicating the total number of duties that can be completed within the time limit. If no duties can be completed, print "I need to find friends." (without quotes)
Sample Input 0
3 10
Brayflox's Longstop
1 2
Sastasha
3 2
Urth's Fount
6 6
Sample Output 0
3
Sample Input 1
3 2
Copperbell Mines
13 14
Thornmarch (Hard)
227 228
The Aurum Vale
7 10
Sample Output 1
2
Sample Input 2
4 2
Haukke Manor
117 111
Thornmarch (Hard)
118 115
The World of Darkness
114 113
The Aery
114 110
Sample Output 2
I need to find friends.
The actual code
""" Parameters: Returns: n, t = list(map(int,input().split(" "))) for i in range(n):
|
Step by step
Solved in 4 steps with 2 images