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

×

SWTSHOP - Editorial

Links
Contest
Practice

Author: Anurag Phadnis
Editorialist: Anurag Phadnis

DIFFICULTY:

CAKEWALK

PREREQUISITES:

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.

asked 24 Mar '18, 12:32

alphastar's gravatar image

2★alphastar
295
accept rate: 0%

toggle preview
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:

×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