|
1 |
| -856\. Score of Parentheses |
| 1 | +857\. Minimum Cost to Hire K Workers |
2 | 2 |
|
3 |
| -Medium |
| 3 | +Hard |
4 | 4 |
|
5 |
| -Given a balanced parentheses string `s`, return _the **score** of the string_. |
| 5 | +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. |
6 | 6 |
|
7 |
| -The **score** of a balanced parentheses string is based on the following rule: |
| 7 | +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: |
8 | 8 |
|
9 |
| -* `"()"` has score `1`. |
10 |
| -* `AB` has score `A + B`, where `A` and `B` are balanced parentheses strings. |
11 |
| -* `(A)` has score `2 * A`, where `A` is a balanced parentheses string. |
| 9 | +1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group. |
| 10 | +2. Every worker in the paid group must be paid at least their minimum wage expectation. |
12 | 11 |
|
13 |
| -**Example 1:** |
| 12 | +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. |
14 | 13 |
|
15 |
| -**Input:** s = "()" |
| 14 | +**Example 1:** |
16 | 15 |
|
17 |
| -**Output:** 1 |
| 16 | +**Input:** quality = [10,20,5], wage = [70,50,30], k = 2 |
18 | 17 |
|
19 |
| -**Example 2:** |
| 18 | +**Output:** 105.00000 |
20 | 19 |
|
21 |
| -**Input:** s = "(())" |
| 20 | +**Explanation:** We pay 70 to 0<sup>th</sup> worker and 35 to 2<sup>nd</sup> worker. |
22 | 21 |
|
23 |
| -**Output:** 2 |
| 22 | +**Example 2:** |
24 | 23 |
|
25 |
| -**Example 3:** |
| 24 | +**Input:** quality = [3,1,10,10,1], wage = [4,8,2,2,7], k = 3 |
26 | 25 |
|
27 |
| -**Input:** s = "()()" |
| 26 | +**Output:** 30.66667 |
28 | 27 |
|
29 |
| -**Output:** 2 |
| 28 | +**Explanation:** We pay 4 to 0<sup>th</sup> worker, 13.33333 to 2<sup>nd</sup> and 3<sup>rd</sup> workers separately. |
30 | 29 |
|
31 | 30 | **Constraints:**
|
32 | 31 |
|
33 |
| -* `2 <= s.length <= 50` |
34 |
| -* `s` consists of only `'('` and `')'`. |
35 |
| -* `s` is a balanced parentheses string. |
| 32 | +* `n == quality.length == wage.length` |
| 33 | +* <code>1 <= k <= n <= 10<sup>4</sup></code> |
| 34 | +* <code>1 <= quality[i], wage[i] <= 10<sup>4</sup></code> |
0 commit comments