Associated Course(s):
Geeks Classes in Noida

Given a set of **N** jobs where each job *i* has a deadline and profit associated to it. Each job takes *1* unit of time to complete and only one job can be scheduled at a time. We earn the profit if and only if the job is completed by its deadline. The task is to find the **maximum profit** and the number of jobs done.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Each test case consist of an integer N in first line denoting the number of jobs and the next line consist of Job id, Deadline and the Profit associated to that Job.

**Output:**

Output the number of jobs done and the maximum profit.

**Constraints:**

1 <= T <= 100

1 <= N <= 100

1 <= Deadline <= 100

1 <= Profit <= 500

**Example:**

**Input:**

2

4

1 4 20 2 1 10 3 1 40 4 1 30

5

1 2 100 2 1 19 3 2 27 4 1 25 5 1 15

**Output:**

2 60

2 127

**Explanation:
Testcase 1:** 2 jobs can be done with maximum profit of 60.

Author: Shubham Chaudhary gfg

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

KshatriyaYash | 658 |

RuntimeTerror | 446 |

nikhil_sojan | 388 |

cypherr | 384 |

striver119 | 378 |

KshatriyaYash | 1066 |

nikhil_sojan | 972 |

lonecoder | 909 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4462 |

Quandray | 4444 |

Login to report an issue on this page.