Cody

Solution 1680234

Submitted on 25 Nov 2018 by William
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   Pass
m=[100 1 2 3 4 5 6 7 8 9 10 11 12 ]; BSPexp= [1 12 1100]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

2   Pass
m=[100 52 50 25 100 61 63 70 51 71 55 10 5 ]; BSPexp= [3 4 300]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

3   Pass
m=[100 200 150 250 132 125 110 210 220 180 176 108 113 ]; BSPexp= [0 0 0]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

4   Pass
m=[450 100 132 169 179 194 204 186 180 228 140 145 144 ]; BSPexp= [1 9 512]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

5   Pass
m=[250 12 212 9 89 8 88 7 87 6 86 5 85 ]; BSPexp= [11 12 4000]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

6   Pass
m=[260 199 30 198 16 54 242 12 220 105 78 178 224 ]; BSPexp= [7 12 4452]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

7   Pass
m=[362 96 95 85 126 242 71 144 139 25 198 153 11 ]; BSPexp= [9 10 2422]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

8   Pass
m=[403 133 193 224 246 38 138 103 113 126 154 189 136 ]; BSPexp= [5 11 1510]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

9   Pass
m=[260 126 56 231 199 192 75 87 113 63 70 128 167 ]; BSPexp= [2 3 700]; BSP=Profit(m(1),m(2:end)); assert(isequal(BSPexp,BSP))

10   Pass
% function GJam_Africa_2011B % %fn='B-small-practice.in'; % fn='B-large-practice.in'; % [data] = read_file(fn); % % %fidG = fopen('B-small-output1.out', 'w'); % fidG = fopen('B-large-output.out', 'w'); % tic % for i=1:size(data,2) % BSP = Profit(data{i}(1),data{i}(2:end) ) ;% data 12 vector, % toc % % continue % if BSP(1)==0 % fprintf(fidG,'Case #%i: IMPOSSIBLE\n',i); % fprintf('Case #%i: IMPOSSIBLE\n',i); % % else % fprintf(fidG,'Case #%i: %i %i %i\n',i, BSP); % fprintf('Case #%i: %i %i %i\n',i, BSP); % % end % % end % toc % % fclose(fidG); % end % % function [d] = read_file(fn) % %Read a numeric of lines to count % fid=fopen(fn); % fgetl(fid); % Total Count ignore % set=0; % while ~feof(fid) % M=str2num(fgetl(fid)); % Qty in a row, ignore % P=str2num(fgetl(fid)); % read line of data, convert to vector % % set=set+1; % d{set}=[M P]; % end % fclose(fid); % end % % % alternate read using dlmread; useful for numeric array input files % function [d]=read_dlm_file(fn) % M=dlmread(fn); % q=M(1); % d{q}=[]; % for i=1:q % w=find(M(2*i+1,:)>0,1,'last'); % d{i}=[M(2*i) M(2*i+1,1:w)]; % end % end % % % function BSP=Profit(M,x) % BSP=[0 0 0]; % PU=floor(M./x); % m=repmat(x,12,1)-repmat(x',1,12); % m=m.*triu(ones(12),1); % m=m.*repmat(PU',1,12); % [b,s]=find(m==max(m(:))); % if x(s(1))<=x(b(1)),return;end % ptr=find(x(b)==min(x(b))); % BSP=[b(ptr) s(ptr) max(m(:))]; % end