Держи. На питоне
Объяснение:
n = int(input())
cool_score = 0
jumps = input().split()
sorted_jumps = sorted(jumps)
for i in range(len(jumps)):
if i != len(jumps) - 1:
Ni = jumps.index(sorted_jumps[i]) + 1
Hi = sorted_jumps[i]
if jumps.count(jumps[i]) > 1:
jumps[i] = 'done'
Nj = jumps.index(sorted_jumps[i + 1]) + 1
Hj = sorted_jumps[i + 1]
a = 'abs({} - {}) + {} - {}'.format(int(Ni), int(Nj), int(Hj), int(Hi))
cool_score += eval(a)
print(cool_score)
<html>
<body>
<table border="1" cellspacing="0" height="333" width="333">
<tr>
<td colspan="8"></td>
</tr>
<td rowspan="6"></td>
<td colspan="6"></td>
<td rowspan="7"></td>
<td rowspan="4"></td>
<td colspan="4"></td>
<td rowspan="5"></td>
<td rowspan="2"></td>
<td colspan="2"></td>
<td rowspan="3"></td>
<td></td>
<td colspan="3"></td>
<td colspan="5"></td>
<td colspan="7"></td>
</table>
<br>
</body>
</html>
картинка
Держи. На питоне
Объяснение:
n = int(input())
cool_score = 0
jumps = input().split()
sorted_jumps = sorted(jumps)
for i in range(len(jumps)):
if i != len(jumps) - 1:
Ni = jumps.index(sorted_jumps[i]) + 1
Hi = sorted_jumps[i]
if jumps.count(jumps[i]) > 1:
jumps[i] = 'done'
Nj = jumps.index(sorted_jumps[i + 1]) + 1
Hj = sorted_jumps[i + 1]
a = 'abs({} - {}) + {} - {}'.format(int(Ni), int(Nj), int(Hj), int(Hi))
cool_score += eval(a)
print(cool_score)
<html>
<body>
<table border="1" cellspacing="0" height="333" width="333">
<tr>
<td colspan="8"></td>
</tr>
<tr>
<td rowspan="6"></td>
<td colspan="6"></td>
<td rowspan="7"></td>
</tr>
<tr>
<td rowspan="4"></td>
<td colspan="4"></td>
<td rowspan="5"></td>
</tr>
<tr>
<td rowspan="2"></td>
<td colspan="2"></td>
<td rowspan="3"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<tr>
<td colspan="7"></td>
</tr>
</table>
<br>
</body>
</html>
Объяснение:
картинка