EmployManager
SRM 619 · 2013-12-22 · by hyy5159
Problem Statement
Shiny wants to hire some managers for her company. There are N candidates, numbered 0 through N-1. She can employ any subset of these candidates, including possibly none or all of them.
For each of the candidates we know an amount in dollars Shiny must pay if she wants to hire that candidate.
You are given a
For each pair i < j of candidates we also know a value E(i,j) with the following meaning:
- If both i and j are employed, the company will earn E(i,j) dollars.
- However, if neither i nor j are employed, they will cooperate to harm the company, which will cost the company E(i,j) dollars.
For your convenience, we also define E(i,i)=0 and E(j,i)=E(i,j) for all i and j.
You are given the above values E(i,j) encoded as a
You are given the
Constraints
- value will contain between 1 and 50 elements, inclusive.
- earning will contain the same number of elements as value.
- The length of each element of earning will be the same as the number of elements in value.
- Each character in each element of earning will be a digit ('0'-'9').
- Each element of value will be between 0 and 1000, inclusive.
- For each i, earning[i][i] will be '0'.
- For each i and j, earning[i][j] will be equal to earning[j][i].
{1, 1}
{"02", "20"}
Returns: 0
Hiring both managers is the optimal solution in this example.
{2, 2}
{"01", "10"}
Returns: -1
Here it is best not to hire any manager.
{1, 2, 3, 4}
{"0121", "1021", "2201", "1110"}
Returns: -1
{2, 2, 0, 1, 4, 0, 1, 0, 0, 4}
{"0100451253", "1010518123", "0102989242", "0020093171", "4590045480", "5189400676", "1893500826", "2121468008", "5247872007", "3321066870"}
Returns: 156
{2, 1, 3, 4, 0, 2, 0, 2}
{"00064145", "00133544", "01099618", "63904892", "43940759", "15687082", "44195803", "54829230"}
Returns: 116
Submissions are judged against all 89 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class EmployManager with a public method int maximumEarnings(vector<int> value, vector<string> earning) · 89 test cases · 2 s / 256 MB per case