Cody

# Problem 44787. What can you get for exactly amount of money(harder)

Solution 1677764

Submitted on 21 Nov 2018
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
v = [ 195 125 260 440 395 290]; s = 570; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

ans = 125 195 ans = 3 1 Elapsed time is 0.004519 seconds.

Assertion failed.

2   Pass
v = [ 150 180 60 40]; s = 210; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

ans = 60 150 ans = 1 1 Elapsed time is 0.002559 seconds.

3   Fail
v = [ 150 180 60 40]; s = 1e10; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

ans = 40 ans = 250000000 Elapsed time is 0.000554 seconds.

Assertion failed.

4   Fail
v = [123456, 963852, 753159, 7841, 122]; s = 1e10+19; tic res = buy(v, s); toc assert(sum(res) == s); assert(all(ismember(res, v)))

ans = 122 7841 ans = 81967149 1 Elapsed time is 0.001635 seconds.

Assertion failed.

5   Fail
v = [319,2770,462,972,8235,6949,3171,9503,345,4388,3816,7656,7952,1869,4898,4456,6464,7094,7547,2761,6798,6551,1627,1190,4984,9598,3404,5853,2239,7513]; s = 1e10+19; tic; res = buy(v, s); toc; assert(sum(res) == s); assert(all(ismember(res, v)))

ans = 319 345 ans = 31347731 214 Elapsed time is 0.002494 seconds.

Assertion failed.

6   Fail
v = [3898,2417,4040,965,1320,9421,9562,5753,598,2348,3532,8212,155,431,1690,6492,7318,6478,4510,5471,2964,7447,1890,6868,1836,3685,6257,7803,812,9294,7758,4868,4359,4468,3064,5086,5108,8177,7949,6444,3787,8116,5329,3508,9391,8760,5502,6225,5871,2078]; s = 1e10+19; tic; res = buy(v, s); toc; assert(sum(res) == s); assert(all(ismember(res, v)))

ans = 155 431 ans = 64515979 54 Elapsed time is 0.000517 seconds.

Assertion failed.