Created
April 24, 2017 18:53
-
-
Save canassa/8b36ec26e54f0562ad6deeacf08dccfd to your computer and use it in GitHub Desktop.
maxPart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
from array import array | |
A = array('d', range(3000)) | |
n = len(A) | |
max_sum = -sys.maxsize | |
von = bis = 0 | |
add = 0 | |
start_time = time.time() * 1000 | |
for i in range(n): | |
for j in range(i, n): | |
summe = sum(A[i:j]) | |
if summe > max_sum: | |
max_sum = summe | |
von = i | |
bis = j | |
time_taken = (time.time() * 1000) - start_time | |
print(time_taken) | |
print(max_sum, von, bis) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment