You are not logged in. Please login at to post your questions!


Help me understand the question Chef and Operations

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

pg21priyanka's gravatar image

accept rate: 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 .


answered 17 Oct '18, 11:21

prateek_imkp1's gravatar image

accept rate: 44%

edited 17 Oct '18, 11:23

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) pg21priyanka2★

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 : .

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) prateek_imkp14★

For detailed and clear explanation of Chef and Operations solution ,you can check the editorial - .

(18 Oct '18, 00:00) prateek_imkp14★

Thank you. Got to know something new.

(20 Oct '18, 09:48) pg21priyanka2★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 17 Oct '18, 09:32

question was seen: 307 times

last updated: 20 Oct '18, 09:48