L = [int(input()) for x in range(int(input()))]
L.insert(0, 0)
L.append(0)
ans = 0
cur = 0
values = {}
for x in range(1, len(L) - 1):
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 |
1 |
Correct |
64 ms |
19172 KB |
Output is correct |
2 |
Correct |
59 ms |
19044 KB |
Output is correct |
3 |
Correct |
66 ms |
19012 KB |
Output is correct |
4 |
Correct |
59 ms |
19052 KB |
Output is correct |
5 |
Correct |
57 ms |
19088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
202 ms |
25008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
232 ms |
30932 KB |
Output is correct |
2 |
Correct |
218 ms |
32524 KB |
Output is correct |
3 |
Incorrect |
268 ms |
31480 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1096 ms |
34068 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
34312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |