반응형
cash = int(input())

prices = list(map(int,input().split()))

J = [0,cash]
S = [0,cash]

def J_asset(prices,J):
  for price in prices:
    if J[1]>= price:
        J[0] += J[1]//price
        J[1] = J[1]%price
  
  return prices[-1]*J[0] + J[1]


def S_asset(prices,S):
  for day in range(3, len(prices)):
    if prices[day-3:day][0]<prices[day-3:day][1]<prices[day-3:day][2]:
        S[1] += S[0]*prices[day]
        S[0] = 0
      # print("sell"+str(day))
    
    if prices[day-3:day][0]>prices[day-3:day][1]>prices[day-3:day][2] and S[1] > prices[day]:
        S[0] += S[1]//prices[day]
        S[1] = S[1]%prices[day]
      # print("buy"+str(day))
    # print(J)
  return prices[-1]*S[0] +S[1]

j_asset =J_asset(prices,J)
s_asset =S_asset(prices,S)
# print(j_asset)
# print(s_asset)

if j_asset > s_asset:
    print("BNP")
elif j_asset<s_asset:
    print("TIMING")
else:
    print("SAMESAME")
반응형

+ Recent posts