Is there any greedy approach for finding minimum operations required for making a_i to b_i ?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | djm03178 | 153 |
Is there any greedy approach for finding minimum operations required for making a_i to b_i ?
Name |
---|
This is weird! I think this is because we can know how many operations are needed to get from $$$1$$$ to $$$b_i$$$ greedily.
can you share your greedy approach ?
i've been trying but not able to come up with any!!
We can always choose $$$x = 1$$$ so that when performing $$$a_i = a_i + \lfloor{\frac{a_i}x\rfloor}$$$ is the same as $$$ a_i = 2a_i$$$.
Let $$$b_i$$$ is the minimum number of the above operation to get from $$$1$$$ to $$$i$$$. Sense $$$i <= 10^3$$$ so we need at most $$$\lceil \log_2{10^3} \rceil$$$ operations, $$$b_i \le 10$$$.
Update:
Ops! forget about it, in the last operation we can't increase by all values in the range $$$[1, a_i)$$$. Only some of them are available.
The editorial provided a DP approach for it, check it out.
It tagged greedy because it's a knapsack problem.
By the way, thanks for sharing a great problem to solve.
But the problem can't be solved greedily. The greedy approach only works with the fractional knapsack (as far as I know).
Tags are sometimes wrong.