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

×

SRM 634 250 pt

I tried a greedy approach to solve this question which failed during system testing. I am trying to find proof of incorrectness but am not able to do so. This is my approach.
I first sort vector s(number of customers for each item in reverse order) and start from assigning items with most customers. I have an array a[] which stores the number of items bought by customer i. In each iteration, I sort a[]. For each item s[j],I do the following:
1. Move in increasing order of a[i] and if a[i]+1 is less than K, then give the item to customer i, (decrease s[j] and move ahead) otherwise break and start assigning that item in decreasing order of a[i].
Can anyone tell when this approach will fail?

asked 26 Sep '14, 22:38

thunderking's gravatar image

6★thunderking
166137
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:

×969
×30

question asked: 26 Sep '14, 22:38

question was seen: 383 times

last updated: 26 Sep '14, 22:38

Related questions