Submission #501156

#TimeUsernameProblemLanguageResultExecution timeMemory
501156MrVroom999Nizin (COCI16_nizin)Cpython 3
100 / 100
836 ms30512 KiB
""" COCI 2016/2017 Round 2 Given an array of integers [a1, a2, ... an] perform an operation that combines a1 and a2 or combines an and an-1 Find minimum operations such that array is a palindrome """ N = int(input()) arr = list(map(int, input().split())) k, i, j = 0, 0, N - 1 while i < j: if arr[i] == arr[j]: i += 1 j -= 1 elif arr[i] < arr[j]: arr[i + 1] += arr[i] i += 1 k += 1 else: arr[j - 1] += arr[j] j -= 1 k += 1 print(k)
#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...
#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...