Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Maximizing the reward You are given N tasks with following information: Deadline: Di Reward: Ri Time taken to complete the tasks: Pi The reward

c++

Maximizing the reward

You are given N tasks with following information:

Deadline: Di

Reward: Ri

Time taken to complete the tasks: Pi

The reward is given only when a task is completed within the corresponding deadline.

Write a program to schedule the tasks in order to maximize the reward.

Input format

First line: T (number of test cases)

First line in each test case: N

Next N lines in each test case: Three space-separated integers Di, Ri, and Pi

Output format

For each test case, print the schedule of tasks that maximizes the reward in new line.

Constraints

1 T 10 1 N 103 1 D 103 1 P D 1 R 106

Sample Input

1

6

1 2 1

2 3 1

4 1 2

10 10 10

15 13 10

15 7 5

Sample Output

20

Explanation

If we perform the last two task alone we can get the maximum reward which is 20.

Note: Your code should be able to convert the sample input into the sample output. However, this is not enough to pass the challenge, because the code will be run on multiple test cases. Therefore, your code must solve this problem statement.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

Am I staying angry at someone, hoping to make him or her feel bad?

Answered: 1 week ago