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 |
1 |
Correct |
21 ms |
2892 KB |
Output is correct |
2 |
Correct |
17 ms |
2864 KB |
Output is correct |
3 |
Correct |
21 ms |
2900 KB |
Output is correct |
4 |
Correct |
16 ms |
2900 KB |
Output is correct |
5 |
Correct |
16 ms |
2972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
231 ms |
3912 KB |
Output is correct |
2 |
Correct |
231 ms |
3932 KB |
Output is correct |
3 |
Correct |
229 ms |
4020 KB |
Output is correct |
4 |
Correct |
242 ms |
4048 KB |
Output is correct |
5 |
Correct |
258 ms |
4004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
310 ms |
11092 KB |
Output is correct |
2 |
Correct |
304 ms |
15136 KB |
Output is correct |
3 |
Correct |
289 ms |
11252 KB |
Output is correct |
4 |
Correct |
303 ms |
11624 KB |
Output is correct |
5 |
Correct |
314 ms |
11440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
38632 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
39836 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |