问题
Array with elements sorted in descending order - l
ans=[]
for t in l:
if t<=S:
S-=t
ans.append(t)
if S==0:
break
ans, Gives us list with selected elements.
Please tell me whether it is satisfiable by all big numbers or not?
回答1:
No it doesn't work for all cases:
For example: S = 17 and l = [10,5,4,3]
The answer and will be: ans = [10,5] and S = 2 (because it didn't get down to 0)
But it could have been solved by: ans [10,4,3]
回答2:
For n=8 and omitted element=2. This won't return the right answer.
来源:https://stackoverflow.com/questions/48169568/grouping-of-elements-of-set-with-first-n-natural-numbers-excluding-one-arbitrar