This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
L = [int(input()) for x in range(int(input()))]
L.insert(0, -1)
L.append(-1)
ans = 0
cur = 0
values = {}
for x in range(1, len(L) - 1):
if L[x] == L[x-1] and L[x-1] != -1:
L[x-1] = L[x-2]
if L[x-1] < L[x] > L[x+1]:
if L[x] in values:
values[L[x]] += 1
else:
values[L[x]] = 1
if L[x-1] > L[x] < L[x+1]:
if L[x] in values:
values[L[x]] -= 1
else:
values[L[x]] = -1
for x in sorted(values)[::-1]:
cur += values[x]
ans = max(ans, cur)
print(ans)
# | 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... |