Close
Topic list
Ninja And The Clan
MEDIUM
24 mins
Dynamic Programming
Bit Manipulation
Topics (Covered in this problem)
Problem solved
Skill meter
Dynamic Programming
-
-
Bit Manipulation
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Ninja And The Clan

Contributed by
Rakesh Tiwari
Medium
0/80
Avg time to solve 24 mins
Success Rate 70 %
Share

## Problem Statement

#### Note that each task is assigned to a single Ninja, and each Ninja will only be allotted a single task.

##### EXAMPLE:
``````Input:
'N' = 3
‘COST’ = [[1 2 3],
[6 5 6],
[3 8 9]]

Output: 11

A possible assignment is:
Assign task 1 to ninja 3, task 2 to ninja 1 and task 3 to ninja 2, total cost = 3 + 2 + 6 = 11
``````
Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1 :
``````2
2
10 13
12 14
3
1 1 1
2 2 1
1 2 1
``````
##### Sample Output 1 :
``````24
3
``````
##### Explanation Of Sample Input 1 :
``````For the first test case, a possible assignment can be:

For the second test case, a possible assignment can be:
``````
##### Sample Input 2 :
``````2
3
2 4 6
8 4 2
8 4 8
5
1 3 5 7 4
3 4 9 10 11
1 2 1 2 1
5 4 8 3 3
6 6 6 6 6
``````
##### Sample Output 2 :
``````8
15
``````
Auto
Console