In Chapter DP from permutations to subsets, there is a problem about elevators. There is an elevator with maximum weight x, and n people with known weights who want to get from the ground floor to the top floor. What is the minimum number of rides needed if the people enter the elevator in an optimal order? Help me!!!

I dont now

its easy problem

Noob

Yes

thanks bro

What are constraints of the problem, can you give full statement?

n <= 20 and x <= 10^9

https://cses.fi/problemset/task/1653

You can solve it by dp on submasks (I got it accepted). Define F(mask,last) — pair(number of elevators needed to move all people that mask include, space occupied in the last elevator). We want to make this pair as small as possible (at first we want to have smallest number of elevators (we can always summon one more elevator with 0 occupied space), if it's equal we want to have as much free space in last elevator as possible). We will iterate through all people, whom included in mask, and try to relaxate dp[mask] trough dp[submask], where submask = mask xor (2^last). At first try to add last passenger to an existing elevator. If it's impossible — summon one more elevator and put it there.

code: https://pastebin.com/VPAfgV2s

No problem but you may pay me 50$ or maybe 100$,I don'y know now but I will think about it,ok bye.

don't worry about it ok olimpic_boy,ok bye.

already asked: https://codeforces.com/blog/entry/87032