×

# Help me understand the question Chef and Operations

 1 Help me understand the question Chef and Operations. although i saw some solutions but still unable to understand how to solve. asked 17 Oct '18, 09:32 0●2 accept rate: 0%

 0 You have to start from the first index (0th) and add (b[i]-a[i]) to a[i] (to make it equal to b[i]), (a[i] - b[i])2 to a[i+1] and (a[i] - b[i]) 3 to a[i+2]. Meanwhile if a[i] becomes greater than b[i] at any stage , you need to stop as you cannot subtract to make it equal to b[i]. You can see my solution for clarification https://www.codechef.com/viewsolution/20702777 . answered 17 Oct '18, 11:21 134●7 accept rate: 44% 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. (17 Oct '18, 18:39) 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 . (17 Oct '18, 23:42) For detailed and clear explanation of Chef and Operations solution ,you can check the editorial - https://discuss.codechef.com/questions/137173/qabc-editorial . (18 Oct '18, 00:00) 1 Thank you. Got to know something new. (20 Oct '18, 09:48)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×239
×37
×8
×2

question asked: 17 Oct '18, 09:32

question was seen: 307 times

last updated: 20 Oct '18, 09:48