L = [int(input()) for x in range(int(input()))]
L.append(0)
add = {}
cur = 0
first = 0
peak = 0
flag = False
for x in L:
if not flag:
if x >= cur:
cur = x
else:
peak = cur
flag = True
if flag:
if x <= cur:
cur = x
else:
if peak in add:
add[peak] += 1
else:
add[peak] = 1
if max(first, cur) in add:
add[max(first, cur)] -= 1
else:
add[max(first, cur)] = -1
first = cur
cur = x
flag = False
if peak in add:
add[peak] += 1
else:
add[peak] = 1
if first in add:
add[first] -= 1
else:
add[first] = -1
print(add)
ans = 0
cur = 0
for x in sorted(add)[::-1]:
cur += add[x]
ans = max(ans, cur)
print(ans)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
2924 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
206 ms |
4024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
237 ms |
12328 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
48904 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1055 ms |
48388 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |