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

×

# how to solve manthan codefest17 problemB

 0 problem link http://codeforces.com/contest/855/problem/B asked 24 Sep '17, 23:06 23●5 accept rate: 0%

 0 What I did, was to keep a track of minimum from start upto index i, maximum from start upto index i, minimum from end upto index i, maximum from end upto index i; Now I made cases, and accordingly used the formula (eg- if p<0 use p*min upto index i; if p>0, use p* max upto index i etc.) For every case, you can check liek- For i from 1 to N ans=max(ans, p*max_or_min till i from start + q*arr[i] + r *max or min till i from end);  But I believe making cases was redundant, but i thought better safe than sorry XD answered 24 Sep '17, 23:14 15.4k●1●20●66 accept rate: 18% please give the solution code (24 Sep '17, 23:19) For sake of your own sanity, you shouldnt take a look at my code :3 (24 Sep '17, 23:23) the explaination is enough thank you (24 Sep '17, 23:34)
 0 take four array prefixmin[] (min upto i) prefixmax[] (max upto i) sufmin[] (min from n-1 to i) sufmax[] (max from n-1 to i) fix j form 0 to n-1 for i and k check if p<0 multiply p with premin[i] else multiply p with premax[i] same for r but multiply with sufmin and sufmax and check for more check my code: https://ideone.com/AtQqiJ however my solution got hacked just for one line mx=-1e18 instead LLONG_MIN answered 25 Sep '17, 00:34 2★doramon 86●5 accept rate: 5%
 toggle preview community wiki:
Preview

### Follow this question

By Email:

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

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:

×678
×12
×1

question asked: 24 Sep '17, 23:06

question was seen: 483 times

last updated: 25 Sep '17, 00:36