yeasung240 / algorithm

Records about algorithm theory that I learned
0 stars 0 forks source link

CCC '00 S2 - Babbling Brooks #5

Open yeasung240 opened 6 months ago

yeasung240 commented 6 months ago

Keep getting error on test 5 `

i = 0
totalnum = int(input())
lis = []

while i != 77:
    i = int(input())
    lis.append(i)
    for q in range(len(lis)):
            lis[q] = int(lis[q])

    if i == 99:
        lis.remove(99)
        digit = int(input())
        percentage = int(input())
        left = lis[digit-1] * (percentage/100)
        right = lis[digit-1] - left 
        round(left)
        round(right)
        lis[digit-1] = left
        lis.insert(digit,right)

    elif i == 88:
        lis.remove(88)
        digit2 = int(input())
        combin = lis[digit2-1] + lis[digit2]
        lis[digit2-1] = combin
        lis.pop(digit2)

    elif i == 77:
        lis.remove(77)

for value in lis:
    print(value,end=" ")

`

yeasung240 commented 6 months ago

Answer ` initialNumberOfStreams = int(input()) streamFlows = [] for i in range(initialNumberOfStreams): initialStreamFlow = int(input()) streamFlows.append(initialStreamFlow)

action = int(input()) while action != 77: if action == 99: streamSplitPoint = int(input()) streamSplitPoint -= 1 originalStreamFlow = streamFlows[streamSplitPoint] streamFlowPercentageToLeft = int(input()) streamFlows[streamSplitPoint] = originalStreamFlow (streamFlowPercentageToLeft/100) streamFlows.insert(streamSplitPoint+1, originalStreamFlow (1-(streamFlowPercentageToLeft/100))) else: streamJoinPoint = int(input()) streamJoinPoint -= 1 streamFlows[streamJoinPoint] += streamFlows[streamJoinPoint+1] streamFlows.pop(streamJoinPoint+1) action = int(input())

for i in range(len(streamFlows)-1): print(f"{int(streamFlows[i])}", end = " ") print(f"{int(streamFlows[-1])}")

`