# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1181794 | kemalmete1 | Mountains (NOI20_mountains) | Pypy 3 | 2104 ms | 265540 KiB |
n = int(input())
heights = [int(h) for h in input().split()]
total = 0
while n > 2:
max_val = max(heights)
max_index = heights.index(max_val)
temp = heights.copy()
temp_len = n
i = 0
while i < temp_len:
if temp[i] == max_val and i != max_index:
temp.pop(i)
temp_len -= 1
i += 1
left = max_index
right = temp_len - max_index - 1
total += left * right
heights.pop(max_index)
n -= 1
print(total)
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... |