Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3402260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:06:58+00:00 2026-05-18T05:06:58+00:00

Here is my problem: There are n companies distributing products. All products should be

  • 0

Here is my problem:

  • There are n companies distributing
    products.
  • All products should be distributed in k days
  • Distributing products of company Ci should be consecutive – it means that it can be distributed on days 2,3,4,5 but not 2,3,6,7
  • number of distributed products by company Ci on day j should be less than (or equal) on day j-1 (if there were any on day j-1)
  • difference between distributed products between days i and j should not be greater than 1

Example:

We have 3 days to distribute products. Products of company A: a,a,a,a,a. Products of company B: b,b,b. Products of company C: c,c

Fair distribution:
[aab,aabc,abc]

Invalid distribution:
[aabc,aabc,ab]
because on 1st day there are 4 products, on 3rd day 2 products (difference > 1)

Invalid distribution:
[abc,aabc,aab]
because on 1st day there is one product A, and on 2nd day there are 2 products A, so distribution of product A is not non-decreasing

EDIT
if there is a case that makes fair distribution impossible please provide it with short description, I’ll accept the answer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:06:58+00:00Added an answer on May 18, 2026 at 5:06 am

    Gareth Rees’s comment on djna’s answer is right — the following counterexample is unsolvable:

    • 3 days, 7 items from company A and 5 items from company B

    I tested this with the following dumbest-possible brute-force Perl program (which takes well under a second, despite being very inefficient):

    my ($na, $nb) = (7, 5);
    for (my $a1 = 0; $a1 <= $na; ++$a1) {
        for (my $a2 = 0; $a2 <= $na - $a1; ++$a2) {
            my $a3 = $na - $a1 - $a2;
            for (my $b1 = 0; $b1 <= $nb; ++$b1) {
                for (my $b2 = 0; $b2 <= $nb - $b1; ++$b2) {
                    my $b3 = $nb - $b1 - $b2;
                    if ($a1 >= $a2 && $a2 >= $a3 || $a1 == 0 && $a2 >= $a3 || $a1 == 0 && $a2 == 0) {
                        if ($b1 >= $b2 && $b2 >= $b3 || $b1 == 0 && $b2 >= $b3 || $b1 == 0 && $b2 == 0) {
                            if (max($a1 + $b1, $a2 + $b2, $a3 + $b3) - min($a1 + $b1, $a2 + $b2, $a3 + $b3) <= 1) {
                                print "Success! ($a1,$a2,$a3), ($b1,$b2,$b3)\n";
                            }
                        }
                    }
                }
            }
        }
    }
    

    Please have a look and verify that I haven’t made any stupid mistakes. (I’ve omitted max() and min() for brevity — they just do what you’d expect.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my problem: there's an internal issue tracking system that has a nice summary
My problem is in my navigation bar, which can be found here: http://grupocoral.netai.net/ There
My company has a client that tracks prices for products from different companies at
here is the problem : there is classic asp app which is calling lame.exe
Note: There was not any question with this kind of problem here or anywhere...
I'm not really sure if there is a single problem here or I have
UPDATE Turns out I'm just tired. There isn't any problem here sorry for wasting
date here my problem: String datetime = 2012-03-24 23:20:51; I know that that string
I have a User and Company model. There are three possible roles that a
We have simple div as below. The problem here there is gap between the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.