The statement is really simple.
So basically you've got and shrubs.
And each shrub has got a red berries.
And B I blueberries.
You have some baskets, right?
And each basket contains key berries.
A furnace has decided that each basket may contain only berries, four from the same shrub, sorry,
or berries of the same color, either red or root.
In other words, all bear is in a basket, must be either from the same shrub or and have the same color.
And you are basically asked to feel as many baskets as possible.
And let's take some example.
Right.
The first example, five, two, two, one, two and four.
So you've got to SRAW to Shrub's here in this example.
Five, two.
So five red berries, two blueberries.
And the second shrub was two and one.
So two red berries and one blueberry.
And Kay given Kay was four.
All right.
We have to shrub's and we have some basket's of capacity for.
We have to fill as many as those.
All right.
For this example.
What we can do here is that all right?
So let's right here again, just to remember.
So same color, right?
Same basket has to have all Bury's of the same color and or.
And or.
Same shrub, say.
But for this example, what can I do?
Well, I take a look at the first from.
And I can't be like him.
I have five red berries.
Two blueberries.
Here I have two red.
There is one blueberry.
All right.
So what I can do here is what if I take.
So I need for from here, right?
Right.
So the answer should be to.
But how would they distribute?
Well, that's an interesting question, actually.
Oh, all right, I got it.
So, yeah, it's pretty simple.
What we can do is from the first shrub, take two red berries.
Another two is full of them from the second Trump.
And here we have a basket of four red shrubs.
And yeah, basically for red shirt, red berries.
Right.
And here you've got free more red berries, two more blueberries and of course you can do something
like.
Or free red.
Right.
So you basically have used each and every bery except one.
This one, which was blue.
You haven't used that right?
So you have two baskets which are full on capacity for.
All right, cool.
So I think we've all got the statement right.
Let's jump into the solution.
I was reading this problem.
Right.
After I've got the statement, I was like, all right, let's see the constraint.
M and K.
I read most.
Five hundred and I was like.
Do do do do do do do.
It was already ringing a bell.
Right.
Because what kind of problem is this?
It is an optimization problem.
You have to do something.
We've I don't know as many things as possible.
The cost should be maximum.
The number of things should be minimum.
These kinds of problems are all in the big chunk of optimization problems.
And how do we solve optimization problems?
Of course, DP or greedy, but I haven't thought about some greedy approach.
But when I see this kind of constraints.
Five hundred and five hundred.
I already know it's a DP.
And why is that?
Because greedy approaches do something like sought the input and then take the maximum feeing using
a heap or something like that.
So when you usually have a greedy problem.
But you're going to solve it in something like Biegel of and Logan so that M can be all the way to one
hundred thousand, right?
Two hundred thousand.
One million.
Or at least ten thousand.
Ten thousand.
Yeah, something like that.
But we only have 500.
It's DEPI.
And why is that.
Because we have this 500.
You will be able to do something like an cube.
The time, complexity.
So you've have enough time complexity for a two dimensional DP with the Ricardos in linear time or maybe
one dimensional DP, we have a recurrence in and squared, but that's usually not the case.
Usually the number of dimensions or the complexity of the DP, the array is greater than the complexity
of the recurrence.
That's kind of a rule.
So I read this problem and I was like, hmm, yeah, that's gonna be a DP.
And as you got used to myself.
Before even thinking about the DP.
I've tried to solve the simple problem.
So when I take a look at this problem.
All right.
I have 500 shrubs and capacity K at most 500 hundred, but I have two constraints or two possibilities,
right?
I can make a basket either the same color and or same shrub.
Immediately, I wanted to solve either this problem or this problem.
I won't be able to solve the harder problem if it can't at least solve the same color or the same shrub
problem.
But let's take the same color problem.
I was thinking like this.
All right.
So I have an shrub's.
And I have to feel as many baskets as possible.
We have capacity.
Kate.
And each basket.
Right.
So each basket that I'm gonna feel.
It is going to have Bury's of the same call.
You can change the color, which is going to be nice.
So first possibility.
I'm going to have a basket full of red berries.
But of course, the second possibility here.
I'm going to have Bosket.
Consisting only of blueberries.
Unfortunately, it's not very challenging to solve.
Only these first problem.
Because what you're gonna do, of course, you are going to take each and every shrub.
And let's see if we have some shrub.
So.
That's the let's you raise this.
All right.
So if we have some shrub.
They are just going to take all these red berries.
Store them somewhere in some chunk, in some big, big chunk, a big basket.
All the blueberries store them in a blue big basket.
Let's say.
Then what I'm going to do is I'm gonna take the size of this basket.
And I'm going to divide it by key, and this is how many baskets of capacity.
Kay, I'm gonna obtain which contain only red berries.
Right.
So it's pretty simple.
This size, of course, is the sum of all the A's.
So you have yourself some of all A's, everything divided by K plus some of all the B's, everything
divided by K.
Right.
So it's super simple.
All right.
Unfortunately, it wasn't that challenging to solve this problem, but at least I know how to do.
I was starting to think about same shrub.
Let's take a look at this one.
All right, cool.
So.
I want to have as many baskets as possible.
And in each and every basket, the berries are from the same shrub.
It's even simpler, right?
Or is exactly the same thing?
Well, kind of almost.
What you're gonna do here is that you're not gonna separately take the red berries.
Make there some divide by Kate, the blueberries make their divided by Kate.
From each and every shrub you are taking, each and every berry, no matter the color.
And it into some big basket.
And then you take the size of this basket and divided by key.
So for the second problem, it is the sum of A plus B.
Divided by key.
Right.
But because here we had this sum, all of it divided by this sum, all of it divided by key, here is
the sum of a plus base divided by case or for each and every shrub.
You take A plus B divided by key and added to the sum.
And this is how solve the second problem.
So on this point, after 30 seconds, one minute, I know that I am able to solve each separate problem,
but it's not that challenging, which is not good news, because usually when I solved simple problems,
they were at least as challenging as that.
I had a clue on how to solve the bigger problem with here.
I kind of don't.
Let's erase this and start thinking about the general problem.
All right.
I have and shrubs.
Right.
So I have an.
Dropped each shrub has some.
A, I and B.
Each shrub is independent of the other ones.
But they will have something in common.
Right.
So if I floatable the second sub problem.
I was like, yeah, take the whole shrub and divided by K.
And so.
But here, when I can do both.
What this basically tells me is that I can take from this shrub.
Some red berries.
Then I can take from this shrub some blueberries.
Use those.
Feel some red baskets and some blue baskets.
So let's call a red basket.
This is a Bosket field, we have, of course, only red berries.
Good.
Let's call a blue bosket.
Of course, the same thing, but for blue buried.
Blue berries.
And let's call shrub bosket.
Shrub basket.
A basket filled by only shrub berries.
It's called them, right?
So I will basically have three types of baskets.
That's clear.
Right.
The blue basket.
Only blueberries.
The only blueberries.
Yeah.
The red basket.
Only red berries and the shrub basket.
Only berries from the same shrub.
So when I take a look at each and every separate shrub.
I know that I'm gonna take some of the red berries in order to feel some red baskets.
Some of the blueberries in order to feel some blue basket.
And what remained after taking those in order to feel some shrub baskets, right.
That's pretty clear, isn't it?
At this point, I'm just thinking about some brute force approach, the worst possible brute force approach
doesn't matter.
Basically, this is.
Or each shrub, A, I.
And B, I.
You can fix.
The following thing.
That's not good.
Ah, because this is gonna be B end.
All right.
Let's just call it X and Y.
Yeah, cool.
So we can fix X.
Which means I'm taking x red berries.
Feel some red basket to them.
I'm taking why?
Blueberries to fill some blue baskets with them, fix each and every pear like this.
There are 10 at power, 18.
Doesn't matter.
It really doesn't matter.
We will see later how to optimize that.
Fix some beer.
Right.
This.
And I know this X and this Y, basically in this shrub, I am left with A I plus B I.
Minus X, minus Y.
Total berries.
So for the shrub baskets, I can use berries from the same shrub.
Which means that I'm going to take the rest of these berries and because I don't want to waste them.
I'm going to divide this by key.
Increase the answer by the.
As simple as that.
They'll fix X and Y.
Increase the answer by the remaining Bury's divided by Kate.
But what should I do with this X and Y?
Well, they are increased to the total number of red berries and the total number of blueberries.
So what I'll do here is that I'm going to have something like Tota.
Plus equals X.
And total blue.
Total blue.
Plus equals what?
Just well, like we did on the force of problem, right?
So I have a big basket where I put all the red berries, one for the blueberries, and of course, let's
see, this is a backtracking.
Right.
So for each and every of this and shrubs, I try out each and every pair of this, X and Ys, and for
each of these configurations, I'm going to increase this to my answer.
And at the end of the configuration building, let's say I'm going to have total red and total blue.
So I'm going to have the answer where I increase total red divided by key.
And of course, I increase total blue divided by.
Could I take the maximum between these numbers in all the configuring?
Right.
So you might ask herself.
All right.
Why did you do that?
If this is a backtracking, isn't it useless to think about this?
Well, it's not.
It's not when you don't have any clue about how to solve some problem.
It's super useful to at least go through the worst approach ever, because having the worst approach
is still better than having nothing.
So at this point, I'm thinking about the backtracking.
Yeah, that's right.
Because if I know what's the process behind the backtracking and how it actually works, I'm going to
have some more clues about what to do.
What are the clues here?
The crews are very simple.
If for some shrub I try out X and Y, I always.
I have to know, what is the total red?
What is the total blue?
And that's it, because if I choose X and Y, I'm going to increase the answer right now.
Right.
But I have to store the number of red and blue berries.
I always have to know them somewhere, right.
So at this point.
I am thinking about this.
I know it's a dynamic programming, and now I know that I should store the number of total red berries
that I'm taking separately for the red basket and the total of blueberries that I'm taking separately
for the blue baskets.
So these are my free diversions.
It's still a brute force, but it's a better one than the backtracking, right, though, by thinking
about this backtracking.
I came up with a better dynamic programming.
I'm going to have, of course, free dimensions, right?
First one is always because I'm either reading for the shrubs.
So is I.
At the cost of doing something from the first I shrub's basically this is always the fourth dimension.
Then let's have our.
The total number of red berries that they've taken by now.
Let's have been.
The total number of blueberries that have taken by Paul.
Basically, I know from the get go how to solve this recurrence relation because it is going to simulate
the backtracking, right?
This is another advanced.
Finally, the backtracking, the recurrence relation is just a simulation of the backtracking.
So what did I do there?
I was fixing each and every pair of X and Y.
Right.
So for the recurrence relation, go with each pair.
X greater or equal than a of I let.
Sorry, sorry.
And Y less or equal then B of I.
So I take x red berries.
Why blueberries?
And what do I do here?
Is that.
If from the first I shrub's I've taken are red berries and blue and B blueberries.
And from this current one, I'm taking X and Y.
That means that from the first I minus one shrub's.
What is that.
I make the dynamic programming kind of backwards.
You can do it to have it like front, like updating some other piece.
It's really your choice.
Doesn't matter.
So I have here I am minus one and R minus X.
But we didn't say what is this dynamic programming going to store?
We haven't defined it yet.
All right.
I'm going to have the maximum number of baskets, exactly what the problem asks for.
So the maximum number.
That I can feel.
Using the first so using the first eye.
Let's say like this first.
I grub's.
Are separate.
Bet there is.
So let's call this extra, so are extra.
Red berries.
So red berries that I use.
Or the red basket's and blue and be extra.
So DP stores the maximum number of baskets.
So I've taken eggs, I've taken why?
So.
And basically taking this value and they increase it by what?
First of all, remember how many berries I have left in the IV shrub, which is a of I plus V of I,
minus X minus Y divided by K.
And these are going to be the shrub baskets that I'm going to feel.
We have the remaining berries.
And that's it, basically, that's it.
Why is that?
Because, of course, I'm going to count only.
This one's because on the end, I am basically taking each and every DEPI of I, R and B, and I'm going
with this value from the DP.
So this value from the DP plus these are divided by K plus it's blue, divided by K.
And of course I am updated.
I am updating the Ansary this value.
If this value is greater than the.
I basically have a DP which simulates the backtracking, but because it's a DP and it stores this value
in memory.
It's of course better than trying out each and every possible configuration.
But come on, let's take a look at this approach.
It's still very naive, right?
This approach is still super naive.
And why is that?
Because.
I wait till the end of the DP in order to increase this costs.
So I basically increase in the deepest value, only a shrub baskets.
And I wait until the end of the DP in order to increase air divided by K plus B divided by K, which
is not cool.
I can do this.
Directly in my recurrence relation.
Right.
And this is what we're gonna do.
Instead of DEPI of I r b.
All right.
So.
Still, DEPI of I Arby.
But cool.
But.
A maximum number of baskets we are going to feed on the first ice dropped.
Meaning of R and B is a little bit changed.
And it's not how many total extra red berries I've taken.
But it's going to be.
That's total.
At total extra red berries, I've taken Modula.
Let me see if I have.
I have to charge my laptop.
Wait a second.
All right.
I haven't felt it would have been a tragedy to shut it down right now.
So.
All right.
So these are.
It's not the total are, but the total are more low key.
And why is that?
And be, of course, the same.
Going to be total be.
More low key, and it's pretty obvious why we're doing that, because in the recurrence relation now,
when we try out each and every pair.
X and Y.
Again, are going to take the value from the first I minus one Shrub's.
Right.
We've.
This, ah, is now the rest of total ah Mordialloc.
So we have to be careful from our.
We will subtract X.
But afterwards, we will have this modulo key.
And exactly the same.
But it's true for that being.
So B minus Y more modulo K.
And now this value is not only increased by A of A plus B of A minus X minus Y divided by K.
But he's also increased by.
I take x rayed the berries.
Of course, that if I take more than K red berries, I'm going to have at least one more extra red basket.
So I'm going to computer right now.
What are the number of red baskets?
All right.
That I obtain instead of storing in this dimension over and over again.
The total number of red berries when that number exceeds its key.
I'm going to increase the DEPI by one and not store it in the dimension.
Right.
It's not so smart to store it there.
So.
What happens here is that it is this value plus X divided by K plus Y divided by K.
And these are the red.
Straw baskets that I obtain right now.
The blue extra baskets that they obtain right now.
And of course, this is the shrub bosk is that they're up there right now.
And.
Of course, the rest modulo key is exactly like this.
Right.
So what happened basically here is that.
Let's say if we took.
X equals 14 or something.
If X equals 14 and K equals four, I notice right now that I have free more red basket's.
And I have one extra red berry that, of course, is not in some of those baskets, so it's extra.
So this extra red berry is going to be increased here on this dimension, right?
So it's exactly the same solution, but it's way, way, way better.
And that is because.
Let me erase this right here.
It is a lot a lot better because instead of having that total ah and total B, which could be very,
very large, you now have total are more Jalloh K and total be more drunkie.
So this is at least at most and of course this is at most key.
And this is at most, Kate.
So now only the dynamic programming that these free dimensions are Bigo of M crossed.
K squared.
Which is better.
This is a better approach.
But, of course, it's still not optimal.
And we still have to be smarter about this and we will.
And basically, there was one observation that I've made when thinking about this.
That changed everything because I am going gonna basically take this dynamic programming and improve
it.
First of all, improve the recurrence relation, which was fixing each X and Y.
And those are very big.
And then.
Basically, that's it.
So.
Make that observation.
So I have a red berries, right?
These are the A.I. Redbridge.
And these are the B I.
Blueberries, let's say.
That we have to ask ourselves the following.
If I have exactly, Kate.
Red berries in the same shrub
isn't always the best idea or a good idea to take all those key berries and stored them in a separate
shrub in a separate red basket.
Sorry.
So take.
Always.
K, red berries.
And stored them in extra red baskets.
Well, not really.
You might need those.
But that was a good way of thinking.
So let's say have K red berries, K red berries, K red berries and I have an extra.
Of course, the reminder, a Mordialloc here exactly like this.
K red berries.
K.
Blueberries.
K blueberries.
A blueberries.
And so on and so forth.
And then I have an extra.
Of B I modulo.
But let's think about those red berries.
So you might take an example and see that it's not always optimal to take those batches of K red berries
and have some extra red basketry of them you might need to preserve to keep some of them in order to
combine them with some of these blue extra berries.
But this way of thinking, it's quite complicated, right?
Because I'm like, hmm, if I don't want to fix that X and Y.
How many red I take, how many blue I take, which is quite large because this A and B could be 10 at
Power nine.
I really have to be smarter about this and come up with with your approach and the with your approach
that I thought of was then very simple because.
By now, I was thinking about the problem from let's start from zero baskets, basically.
Let's start with no basket at all and try to fill baskets filled baskets, filled baskets, filled baskets.
And then I noticed that.
But if I thought, what if I thought about it like this?
What if I take all the berries in each and every shrub?
And suppose.
You can feel the maximum number of shops, which is the total number of Bury's in all the shrub's divided
by key, right?
So if I take all the berries and divide those by key, that means that's obviously the maximum number
of baskets I can feel.
But I might not be able to do that.
Right.
To use each and every berry in some basket, because I have those two constraints.
What I thought about them.
The following thing.
Let's say I have this and shops, right?
A one, B one.
B to dot, dot, dot, A and B end, right?
The best case scenario is to take each and every bury, so have the sum of all the berries of A plus
B.
I.
If I, of course, from one to.
And have this some.
Right.
All of this sub divided by.
And that's the best case in it.
But I won't always be able to take all of these berries and divide by key.
Right.
So I thought.
What's going to be extra?
What's going to be not in place?
Right.
If let's say I have a total total of.
And I can't use all of them to fill baskets with only something like 40 for.
What are those six bear is going to be?
I thought about this or.
When I had only the second sub problem, remember, we've only shrub basket.
So I can feel only shrub baskets when I had.
That's a problem.
It was like.
Only shrub baskets.
All right.
It was basically the best case scenario.
That was the answer.
But now the problem is.
That I might have some extra right?
Let me think how I put this.
All right, good.
So.
Aw.
All right, all right, all right.
All right, that's right.
That's right.
Yeah.
So for the first problem.
Sorry about that.
The first problem, remember, the answer was some A plus B, these some was divided by.
And the best case scenario is all.
Is the whole sum divided by key right at end terms and everyone divided by key?
So what is the main difference here and why?
I can't always obtain all the berries.
Is that there are going some extra berries going to be left and kind of not used of.
All right.
So I was like, all right.
I have a total.
In all these shrubs, I have a total.
And a total.
Of, let's say, SB blueberries.
Right.
I have a total of.
As a red berries.
And the total of S.B BlueBell.
If I'm not taking as a.
As SB.
I'm going to miss some red berries from here and some blueberries from here.
And those are going to be the extra berries that I can't take in the whole summer.
Right.
And then I thought about this.
Let's take an example where from all the berries.
Missing x red berries.
And why blueberries?
So we have the rest of the berries.
I could feel baskets and I had some red basket.
So on, so forth.
Then I had a couple of blue bosket.
Blue baskets.
And then I had some prob bosket.
Rob baskets, right?
No, I was able to feel all of these baskets, red baskets, blue baskets and schraub baskets, and
I have an extra of x red berries and wild blueberries that I can't use.
Well, the nice thing to notice is.
Of course, you might think about this.
Mm hmm.
So.
I can fix X and Y and ask myself the following question, if I fix X and what?
Can I use a total of as a minus X red berries and S B minus Y blueberries in order to fill basket's.
But it's not even necessary to fix both of them because this Y is always going to be zero, or you can
think about this X always going to be you can choose one of them.
And why is that?
Because let's suppose you have.
I don't want to read berries left and free blueberries.
All right.
This means that I can take this through this free blueberries, and if I wasn't able to store them in
a whole blue basket at least.
Blue basket, like extra strawberries, right?
I feel that basket and I'm like, Mom, let's put this free on that basket too, or maybe take these
two red berries and let's have these two.
On a basket, too.
So my point is, is that
you're gonna take all the berries in all this and shrubs and you will have.
A couple of red berries, only red berries, which would be extra.
And you have to minimize that number of red berries, right?
We have proved right.
Now, we have proven that there is not gonna be any red and blue berries extra because if there is.
All right.
Take a couple of them and put them in some basket of their own.
Right.
So what's going to happen here is that you will try to do the following thing.
Instead of that dynamic programming, which you will construct the baskets from scratch, you will have.
Find the minimum X.
The minimum X, which is the extra number of red berries such that.
You can feel baskets from all the and shrubs.
Right.
So from the end, shrubs.
You can feel bosket.
Il Bosket.
Extra x red berries, which you haven't you?
But you couldn't use you couldn't make a red basket with them because they are less than gay.
You couldn't ask them to another shrub basket in order to feel it or something like that.
So they are extra.
You should find the minimum egg such that this happens.
And if you found it.
The answer is going to be as a plus S.B, which is the total number of Bury's minus that X, because
you're not going to use those.
All of it divided by key.
So instead of starting from scratch and asking myself, what is the maximum number of baskets I can
feel?
I start from all the berries and I ask myself, what is the minimum number of berries that I'm not going
to use?
And then the rest of them are going to be used perfectly in some basket.
So they're number divided by Kate is going to be our end.
And as we've seen, it will always.
Have only some red berries which are going to be extra.
You won't have.
Red and blue.
So I just have to find that X and then because I know is dynamic programming, I'm gonna use the dynamic
programming approach to find it.
And look how I did.
So and shrubs fill baskets.
Extra extra red berries.
Looks like two dimensions, right?
I don't care how many baskets I feel right now.
Right.
I don't count the number of baskets because I'm gonna know at the end of it.
How many are those?
I'm just counting.
Like my current shrub and how many extra red berries I've taken by.
What will I do here is that DP?
Is true or false?
Whether I can from the first I shrub's.
So from the first I shrub's.
Use all.
All the berries except I red berries.
Though all of them except I read barriers and we've all this Bury's.
To feel.
That I can do this on.
Of course, if I notice this dynamic programming, I'm going to take the minimum X such that DBI of
and and X is true is true.
So that means, alright, I can have an extra X Redbirds that I won't use.
The rest of them are going into Baskett.
And that's it.
The recurrence relation is pretty simple.
And why is that?
Well.
It is exactly like a Ford dynamic programming that we actually did.
And that is.
And basically, my cup, my current shrub is the IV shrub.
Right.
So I'm thinking if I am at the IV shrub, I have to feed.
How many extra red berries?
I'm going to have from this shrub?
I'm trying out each and every.
Let's call it the.
Between.
Zero.
And K minus one.
Between zero and minus one.
Right.
And why is that?
Because.
How could these days be something like Caples Plus?
I can't have K plus two extra red berries because.
That's a contradiction right there, because this K form alone, some redBus.
So another nice thing is that this X is also always less or equal then, Kate.
You can't have more or less strictly in case.
Sorry.
Sorry about that.
You can't have more than or equal to K red berries because, of course, you have more red baskets from
those.
So this X is always less than Kate DEPI of I and X.
I am trying out each and every team.
And I am thinking about this.
All right.
Can I have the extra red berries taken from this bus or from this shrub.
Well, when can I do that?
It's not that hard if you think about it.
If we know for sure.
That these deep red berries are extra.
So we are not using them.
We put them in some place and we say, all right, we're not going to use those.
That's it.
Remain we have a I minus the.
Red berries that we are surely going to use and because we are surely going to use the.
We are taking the reminder of them modulo key, because if this is A I minus B, remember the previous
drawing, we'll have, of course, some case here.
And of course, the rest, which is AA minus demodulator key here.
And these ones are extra baskets like red baskets.
And these ones are the one who remain.
What we're gonna do is this once.
Well, the only possible scenario in which I can use those.
Is when I take them.
If the blueberries and form a shrub basket by themselves, and that's it.
So what we did here is that we try out each and every team.
The number of extra red berries from this shrub.
And for each and every team we are remaining.
We have a total of eight minus the red berries, which we surely going to use.
So if we surely going to use those, we are going to have those ones taken of K of K, of K in groups
of K in red baskets and the remaining of a minus A of A minus T modulo K.
This is going to be taken with all the blueberries and form a shrub basket by themselves.
Of course, if it's possible.
So if A minus T modulo K plus B of eye is greater or equal, then K then it's possible.
So if this holds true and it's possible then depi of I n x.
B of I and eggs.
To be updated with the value of DEPI of IE minus one.
And we wanted exactly X extra red berries here.
And because we are using these, we will have X minus the extra berries.
So if this was true and from the first I minus one shrub's, I can not use X minus the red berries.
And I don't use from this shrub.
Exactly.
Directories.
And I can do that.
This also becomes.
So this is it started from the backtracking.
I had some idea.
Turned it into a dynamic programming.
Then I thought about it the opposite way.
Not starting from scratch and building those baskets, but starting from all the berries and minimize
the number of berries that we are not going to use.
And for doing that, we have also this dynamic programming.
As I've told you the answer, I'm gonna have, of course, the total number of berries as A plus as
B minus this minimum ex such that DEPI of N and X is true.
Everything divided by Kate.
And that's it.
It's not an easy problem.
I surely have a little bit of trouble solving it, but yeah, basically the hardest thing with this
problem is that most of you and me myself were tempted to think that.
All right.
I should start from scratch and see how many baskets I could feel.
But you can't do this in a good time.
Complexity, or at least I haven't managed to do that.
But if you start from the opposite side and think about I have to minimize the number of berries I don't
actually use.
So I don't have those into baskets.
These are ex red berries.
Plus, why blueberries?
Oh, wait.
There does not have to be some blueberries.
Only red berries.
So what's the minimum number of extra red berries?
Oh, wait.
I can do that.
We have some dynamic programming.