×

Contest
Practice

CAKEWALK

None

# PROBLEM:

You are given predicted sale of N consecutive days of sweet shop and an amount K that is spend when shop is open for one day. Find total profit that can be earned when you are allowed to keep shop closed on any number of days (possibly zero).

# QUICK EXPLANATION:

You will earn profit on a day when sale is greater than the amount spend to keep the shop open. So find sum of all Ai - K such that Ai > K.

# EXPLANATION:

You are given predicted sale on N days and amount K is spend when you keep the shop open for 1 day. So profit on each day equals to Ai – K. So whenever the sale is less than K then it is not profitable to keep the shop open, hence you will keep the shop closed on those days. So the total profit will be sum of all Ai - K such that Ai > K.

Author's solution can be found here.

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

×15,851
×1,688
×861
×1

question asked: 24 Mar '18, 12:32

question was seen: 117 times

last updated: 24 Mar '18, 12:32