N = input("Enter the number of policies :- ")
P = []
Q = []
C = []

for j = 1:N
  P(j) = input("Enter the reorder point for policy " +string(j))
  Q(j) = input("Enter the reorder quantity for policy "+string(j))    
  S = 115
  I = 1
  UD = 0 
  DD = 180
  C(j)=0
  for I =1:180
    if I == DD then
        S = S+Q(j)
        UD = 0
    end
    DEM =int(abs(grand(1,1,"unf",0,99)))
    if DEM <=S then
            S = S - DEM
            C(j) = C(j) + S*0.75 
    else
            S = 0
            C(j) = C(j) + (DEM -S)*18.0
    end
    if S + UD <=P(j) then
        UD = Q(j)
        C(j) = C(j)+ 75.0
        DD = I + 3
    end
    I=I+1
    if I>=180 then
        disp("The reorder point is "+string(P(j)) + " , reorder quantity is "+string(Q(j))+ " and the total cost is INR " + string(C(j)))
        break
    end
  end

  mi = min(C)
  for i = 1:N
    if C(i)==mi then
        disp("The best policy is "+string(i)+" with P("+string(P(i))+") and Q("+string(Q(i))+")")
    end
  end
end