Getting wrong answer on test 2 for the following problem. 1633D - Make Them Equal
My Code 144774883 Please Help.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 150 |
Getting wrong answer on test 2 for the following problem. 1633D - Make Them Equal
My Code 144774883 Please Help.
Name |
---|
Auto comment: topic has been updated by asterisks (previous revision, new revision, compare).
I don't even understand properly your code, like there are many macros and that stuff but I'm pretty sure that there is no knapsack in there, and that was the intended way to solve it.
Your function for finding min no of opeartion to covert ('1' to 'm') is wrong . For m = 31 , you are getting minimum no of steps/operations as '7' but the minimum no of steps for m = '31' is '6' .
Edit :- Here is how you get 31 — [ 1 --> 2 --> 4 --> 8 --> 16 --> 21 --> 31 ] ( in 6 steps )
Can you give the right approach please?
You can use bfs to calculate minimum number of steps to reach B[i] from 1 or use an array to precalculate. I used an array.
You can precalculate this before test cases. Here is my submission
Link for codeforces