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⁹

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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 algorithm in the problem. Make sure both test cases return correct answers.

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

"""
This function solves a test case.

Parameters:
n      : int        - number of duties available
t      : int        - time to do duties in minutes
duties : array-like - a 3-tuple of string values in the format (name, wait time,
                      completion time)

Returns:
A string containing the answer or "I need to find friends."             
"""
def solve(n,t,duties):
    # TODO
    pass

n, t = list(map(int,input().split(" ")))
duties = []

for i in range(n):
    name = input()
    w,c = list(map(int,input().split(" ")))
    duties.append([name,w,c])


print(solve(n,t,duties))

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⁹
Transcribed Image Text: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⁹
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY