This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
def minimumOperations(arr):
n = len(arr)
dp = [0] * n
for i in range(1, n):
if arr[i] >= arr[i-1]:
dp[i] = dp[i-1]
else:
dp[i] = min(dp[i-2] + 1, dp[i-3] + 1)
return dp[n-1]
n=input()
arr=list(map(int,input().split()))
print(minimumOperations(arr))
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |