Help me understand the question Chef and Operations

and
operations

#1

Help me understand the question Chef and Operations. although i saw some solutions but still unable to understand how to solve.


#2

You have to start from the first index (0th) and add (b*-a*) to a* (to make it equal to b*), (a* - b*)2 to a[i+1] and (a - b*) 3 to a[i+2]. Meanwhile if a becomes greater than b* at any stage , you need to stop as you cannot subtract to make it equal to b*.

You can see my solution for clarification https://www.codechef.com/viewsolution/20702777 .


#3

Can you please tell me the use of #define io std::ios::sync_with_stdio(false);cin.tie(NULL);
I have recently started competitive programming so I am unable to understand its use.


#4

Ya sure . Actually std::ios::sync_with_stdio(false);cin.tie(NULL); is for fast input output. Sometimes your code may get TLE even if your solution is optimal (usually when input file is large) . You can learn more about fast input output here : https://discuss.codechef.com/questions/53203/fastest-io-c .

And as far as #define io std::ios::sync_with_stdio(false);cin.tie(NULL); is concerned , I have a saved template which I use in every code I write .So it is better to use #define in template instead of writing sync_with… every time .


#5

For detailed and clear explanation of Chef and Operations solution ,you can check the editorial - https://discuss.codechef.com/questions/137173/qabc-editorial .


#6

Thank you. Got to know something new.