Cody

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

Solution 1677794

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)))

Error using repelem Requested 1x2500000000 (18.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in buy (line 2) y = repelem(v(1),25e8); Error in Test1 (line 4) res = buy(v, s);

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

Error using repelem Requested 1x2500000000 (18.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in buy (line 2) y = repelem(v(1),25e8); Error in Test2 (line 4) res = buy(v, s);

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

Error using repelem Requested 1x2500000000 (18.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in buy (line 2) y = repelem(v(1),25e8); Error in Test3 (line 4) res = buy(v, s);

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)))

Error using repelem Requested 1x2500000000 (18.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in buy (line 2) y = repelem(v(1),25e8); Error in Test4 (line 4) res = buy(v, s);

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)))

Error using repelem Requested 1x2500000000 (18.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in buy (line 2) y = repelem(v(1),25e8); Error in Test5 (line 4) res = buy(v, s);

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)))

Error using repelem Requested 1x2500000000 (18.6GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information. Error in buy (line 2) y = repelem(v(1),25e8); Error in Test6 (line 4) res = buy(v, s);