There's an algorithm problem.

there are N positive integers in an array. I hope to find out that the sum of M numbers is equal to or closest to a positive integer S

.

for example, this array [1, br 2, 4, 6, 8, 10, 15, 16, 16, and 19], I hope to find out that the sum of 5 numbers is equal to 15, but there are multiple results [1, 2, 4, 4, 8] = 21 [1, 2, 4, 4, 6, 13, to see which is the higher weight of M and S, to sort

.
Php
Nov.27,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3f91f-3486d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3f91f-3486d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?