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

×

hotels spoj O(n) solution

 0 http://www.spoj.com/problems/HOTELS/ Is there any O(n) solution to this problem asked 17 Jul '14, 08:12 4★pyush 3●1●1 accept rate: 0%

 1 Using 2 pointers, pL and pR, tracing cost sum between pL..pR. Initially pL=pR=1; if cost above limit, advance pL; otherwise advance pR. Recording the maximum cost below M during the process. When pR > N, you get the global maximum. answered 17 Jul '14, 08:42 5★tec 304●1●1●8 accept rate: 21% i applied the same logic . But is there any better logic? (17 Jul '14, 08:57) pyush4★ It is already O(n). what type of logic do you expect? (17 Jul '14, 11:25) tec5★
 0 can u please explain it using kadane's algorithm? answered 20 Jun '15, 11:52 1 accept rate: 0%
 toggle preview community wiki:
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "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:

×38

question asked: 17 Jul '14, 08:12

question was seen: 4,718 times

last updated: 20 Jun '15, 11:52