-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 18 additions & 19 deletions
37
src/main/kotlin/g0801_0900/s0857_minimum_cost_to_hire_k_workers/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
856\. Score of Parentheses | ||
857\. Minimum Cost to Hire K Workers | ||
|
||
Medium | ||
Hard | ||
|
||
Given a balanced parentheses string `s`, return _the **score** of the string_. | ||
There are `n` workers. You are given two integer arrays `quality` and `wage` where `quality[i]` is the quality of the <code>i<sup>th</sup></code> worker and `wage[i]` is the minimum wage expectation for the <code>i<sup>th</sup></code> worker. | ||
|
||
The **score** of a balanced parentheses string is based on the following rule: | ||
We want to hire exactly `k` workers to form a paid group. To hire a group of `k` workers, we must pay them according to the following rules: | ||
|
||
* `"()"` has score `1`. | ||
* `AB` has score `A + B`, where `A` and `B` are balanced parentheses strings. | ||
* `(A)` has score `2 * A`, where `A` is a balanced parentheses string. | ||
1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group. | ||
2. Every worker in the paid group must be paid at least their minimum wage expectation. | ||
|
||
**Example 1:** | ||
Given the integer `k`, return _the least amount of money needed to form a paid group satisfying the above conditions_. Answers within <code>10<sup>-5</sup></code> of the actual answer will be accepted. | ||
|
||
**Input:** s = "()" | ||
**Example 1:** | ||
|
||
**Output:** 1 | ||
**Input:** quality = [10,20,5], wage = [70,50,30], k = 2 | ||
|
||
**Example 2:** | ||
**Output:** 105.00000 | ||
|
||
**Input:** s = "(())" | ||
**Explanation:** We pay 70 to 0<sup>th</sup> worker and 35 to 2<sup>nd</sup> worker. | ||
|
||
**Output:** 2 | ||
**Example 2:** | ||
|
||
**Example 3:** | ||
**Input:** quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3 | ||
|
||
**Input:** s = "()()" | ||
**Output:** 30.66667 | ||
|
||
**Output:** 2 | ||
**Explanation:** We pay 4 to 0<sup>th</sup> worker, 13.33333 to 2<sup>nd</sup> and 3<sup>rd</sup> workers separately. | ||
|
||
**Constraints:** | ||
|
||
* `2 <= s.length <= 50` | ||
* `s` consists of only `'('` and `')'`. | ||
* `s` is a balanced parentheses string. | ||
* `n == quality.length == wage.length` | ||
* <code>1 <= k <= n <= 10<sup>4</sup></code> | ||
* <code>1 <= quality[i], wage[i] <= 10<sup>4</sup></code> |