#### 原题说明

Given an array of prices `[p1,p2…,pn]` and a `target`, round each price `pi` to `Roundi(pi)` so that the rounded array `[Round1(p1),Round2(p2)…,Roundn(pn)]` sums to the given `target`. Each operation `Roundi(pi)` could be either `Floor(pi)` or `Ceil(pi)`.

Return the string `“-1”` if the rounded array is impossible to sum to `target`. Otherwise, return the smallest rounding error, which is defined as Σ |Roundi(pi) - (pi)| for i from 1 to n, as a string with three places after the decimal.

Example 1:

`Input: prices = [“0.700”,”2.800”,”4.900”], target = 8Output: “1.000”Explanation: Use Floor, Ceil and Ceil operations to get (0.7 - 0) + (3 - 2.8) + (5 - 4.9) = 0.7 + 0.2 + 0.1 = 1.0 .`

Example 2:

`Input: prices = [“1.500”,”2.500”,”3.500”], target = 10Output: “-1”Explanation: It is impossible to meet the target.`

Note:

1. `1 <= prices.length <= 500`.
2. Each string of prices `prices[i]` represents a real number which is between 0 and 1000 and has exactly 3 decimal places.
3. `target` is between 0 and 1000000.

#### 解题思路

1. 如果取最小的可能的和，那么所有数字都要取floor。如果这个和仍然比target大，或者比`target-pqsize`小，那么就说明无论如何也不可能得到`target`。这样我们就返回 `“-1”`
2. 若满足上述条件，我们一定可以取到满足题目条件的和。我们需要知道调整多少个数字，即把floor操作变成ceil操作。需要调整的数字个数等于`target-pqsize`
3. 为了的达到最小的`rounding error`，对于每个调整的操作，我们希望它们小数尽可能大，这可以由之前的`priority queue`得到。取那个数字的`ceil`。最后把所有不需要调整的小数也加上，就是最小的`rounding error`了。

#### 归纳总结

------ 关注公众号：猩猩的乐园 ------