# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1149410 | maomao | Mountains (NOI20_mountains) | Pypy 3 | 2069 ms | 327680 KiB |
'''
https://oj.uz/problem/view/NOI20_mountains
Score: 64/100
'''
n = int(input())
height = [int(x) for x in input().split()]
ans = 0
while len(height)>=3:
left = []
right = []
maxvalue=max(height)
numofmax = height.count(maxvalue)
for k in range(numofmax):
m = height.index(maxvalue)
for i in range(0,m):
if height[i] < height[m]:
left.append(height[i])
for i in range(m+1,len(height)):
if height[i] < height[m]:
right.append(height[i])
ans += len(left)*len(right)
height.pop(m)
print(ans)
Compilation message (stdout)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |