Submission #1204406

#TimeUsernameProblemLanguageResultExecution timeMemory
1204406ofozBigger segments (IZhO19_segments)Pypy 3
0 / 100
140 ms48820 KiB
from collections import deque from sys import setrecursionlimit def solve(): n = int(input()) a = list(map(int, input().split(" "))) curRight = 0 res = 1 for i in range(n-1, -1, -1): curLeft = 0 curRight += a[i] for j in range(i): curLeft += a[j] if curLeft > curRight: continue cur = 0 seg = 2 prv = curLeft for k in range(j+1, i): cur += a[k] if cur > curRight: seg = -1 break if cur > prv: seg += 1 prv = cur cur = 0 res = max(res, seg) print(res) """ let mx[i] denote the maximum number of segments you can create up to the i-th point. let cur[i] denote, out of all these maximum numbers of segments, the lowest ending sum of them all. """ solve()

Compilation message (stdout)

Compiling 'segments.py'...

=======
  adding: __main__.pyc (deflated 31%)

=======
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...