any idea how its done https://codingcompetitions.withgoogle.com/codejam/round/000000000043585d/00000000007549e5
i am trying to sort but i am so confused atleast explain me the basic idea of how this can be solved i tried this but it didnt solve
'''python
T = int(input()) import math def get_value(number1,number2): cost = 0 if number1 == number2: number2 = number2*10 cost=1 elif number2>number1: cost=0 else: digit1 = int(math.log10(number1)) digit2 = int(math.log10(number2)) if digit1 == digit2: cost+=1 number2 = number2*10 else: list1 = [int(i) for i in str(number1)] list2 = [int(i) for i in str(number2)] number2 = number2*10*(digit1-digit2) cost+= (digit1-digit2) while(int(math.log10(number2))<int(math.log10(number1))): number2=number2*10 cost+=1 if number2==number1: number2+=1 elif number2<number1: digit2 = int(math.log10(number2)) number2 = (number1-number2)+number1 cost+= int(math.log10(number2))-digit2 print(number1,number2,cost) return cost,number2 for j in range(T): n = int(input()) lista = list(map(int,input().split())) back = lista[0] ans = 0 for number in lista[1:]: cost,number= get_value(back,number) ans+=cost back=number if j != (T-1): print("Case #"+str(j+1)+": "+str(ans)) else: print("Case #"+str(j+1)+": "+str(ans), end='')
'''
https://stackoverflow.com/questions/67030107/codejam-2021-append-sort April 10, 2021 at 09:51AM
没有评论:
发表评论