-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path144A.py
More file actions
35 lines (27 loc) · 688 Bytes
/
Copy path144A.py
File metadata and controls
35 lines (27 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
n = int(input(''))
s = str(input(''))
l = s.split(" ")
list = []
for items in l:
soldier = int(items)
list.insert(len(list),soldier)
Max = max(list)
Min = min(list)
index_min = []
index_max = []
if Max != Min:
for i in range(0,len(list)):
if list[i] == Max:
index_max.insert(len(index_max),i)
elif list[i] == Min:
index_min.insert(len(index_min), i)
n_swap = 0
swap_max = min(index_max)
swap_min = max(index_min)
if swap_min < swap_max:
n_swap = len(list) - 1 - swap_min + swap_max - 1
elif swap_min > swap_max:
n_swap = len(list) - 1 - swap_min + swap_max
else:
n_swap = 0
print(n_swap)