Advertisement
PlotnikovPhilipp

Untitled

Oct 28th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. number = int(input())
  3. arr = [int(i) for i in input().split()]
  4. amountOfElement = len(arr)
  5. best = 0
  6. result = 0
  7. i = 0
  8. while i < amountOfElement:
  9.     summ = 0
  10.     j = i
  11.     counter = 1
  12.     while j < amountOfElement:
  13.         if counter % 2 == 0:
  14.             summ += -arr[j]
  15.         else:
  16.             summ += arr[j]
  17.         best = max(summ, best)
  18.         j += 1
  19.         counter += 1
  20.     result = max(best, result)
  21.     i += 1
  22. print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement