non-decreasing sequence

Run Settings
LanguagePython
Language Version
Run Command
def non_decreasing_sequence(boxes,chocolates): #print(boxes) #print(chocolates) diff= [] for i in range(0,len(chocolates)-1): if chocolates[i] > chocolates[i+1]: diff.append(chocolates[i] - chocolates[i+1]) return sum(diff) if __name__ == '__main__': boxes = int(input()) chocolates = [] for _ in range(0,boxes): chocolates.append(int(input())) print(non_decreasing_sequence(boxes,chocolates))
Editor Settings
Theme
Key bindings
Full width
Lines