I have written this code for problem 494A Div 1 Treasure Link==>https://codeforces.net/problemset/problem/494/A code==>55202990 My idea is that start from left and always have the differences between '(' and ')' (How many '(' with no ')' match we have ==> name this variable l)
and then every time we get to an '#' we get the numbers of continuous ')' after that '#' until we face a '('. then the answer for that '#' is cnt(number of continuous ')' from '#') — l .
But my code gets WA for test case 10 what is the problem with my observation?
Please Help!
Hi bro.
I didn't understand your idea. (better written in persian! LOL!!)
But I solved it and this is my idea.
On every
#
you reach you have to replace it with how many ) you want.You can use all of the
)
at the end, But you are supposed to use at least 1 per each#
.Count the number of
)
you have to put. Then per each#
put 1 except the last. Put all of the remaining for the last.At the end you have to check if it is correct or not.
And here is the code. 55206846
I hope you understand my English. xD
Thank you very much