# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1149412 | maomao | Mountains (NOI20_mountains) | Pypy 3 | 2102 ms | 304932 KiB |
'''
https://oj.uz/problem/view/NOI20_mountains
https://github.com/noisg/sg_noi_archive/blob/master/2020_prelim/solution_writeup/NOI_2020_Prelims_Solution.pdf
Score: 64/100
'''
n = int(input())
height = [int(x) for x in input().split()]
ans = 0
while len(height)>=3:
maxvalue=max(height)
numofmax = height.count(maxvalue)
for k in range(numofmax):
left = []
right = []
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... |