×

# MERGING RIVERS {AI04} [PEER]

 0 I actually managed to finish this code but when i submit the answer i get a "Wrong Answer" error. Since the code worked properly for smaller values, i am assuming the error was caused because i didn't use the correct data types (i used long long btw). QUESTION: Can someone tell me the maximum value of output ?? Based on that i will have to edit my code. 'Cause if the output is in range of "long long", then my code might be faulty for higher values. But if its above "long long" then i'll try a little different approach (int array). asked 28 Jan '14, 05:09 2★surf666 1●1●2 accept rate: 0%

 0 I hadn't solved this question before so to better understand it I gave it a shot in Python got AC. From that point since I know I was generating the correct answers I modified my code a little bit to loop over all possible values of n (1<=n<=16384) and kept a variable to keep track of the maximum output value. So to answer your question I found that the maximum output value for any valid case in this range is: 16513 Obviously this tells you that your problem lies in incorrect logic and is not related to a data type issue. Edit: If anyone wants to give this problem a shot the link is here I will leave it to your correctly modify your code but to give you an idea of where to start see the cases below: Your responses to n = 1 through n = 5 Case #1 first meets river 1 at 1 Case #2 first meets river 1 at 2 Case #3 first meets river 3 at 3 Case #4 first meets river 1 at 4 Case #5 first meets river 1 at 620  Correct responses to n = 1 through n = 5 Case #1 first meets river 1 at 1 2 Case #2 first meets river 3 at 23 3 Case #3 first meets river 3 at 3 4 Case #4 first meets river 3 at 23 5 Case #5 first meets river 1 at 11  answered 28 Jan '14, 08:03 2★felic92 384●1●6●11 accept rate: 12% Also notice that there is a space between the word "Case" and the actual number "#N". I feel that neglecting this could also yield WA. (28 Jan '14, 08:06) felic922★
 0 Oh god .... how stupid of me .... I read the question wrong.... i thought river1 meant {1,2,4,8,16, 23, 28...}. Likewise for river2 and river3 .... Now i can do the code ... thanks a lot felic92 SuRF666 answered 28 Jan '14, 21:51 2★surf666 1●1●2 accept rate: 0%
 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:

×1,445
×504
×32
×24
×24
×1

question asked: 28 Jan '14, 05:09

question was seen: 915 times

last updated: 28 Jan '14, 21:51