summaryrefslogtreecommitdiff
path: root/2024/1A.py
blob: ef8b2256cdb8d793f46ee7980dc0d995506df836 (plain)
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
loc1 = []
loc2 = []

with open('1.in', 'r') as file:
    for line in file:
        parts = line.strip().split("   ")
        if len(parts) == 2:
            val1 = int(parts[0])
            val2 = int(parts[1])

            loc1.append(val1)
            loc2.append(val2)

print(sorted(loc1))
print(sorted(loc2))
sorted_loc1 = sorted(loc1)
sorted_loc2 = sorted(loc2)

final_distance = 0

for i in range(len(loc1)):
    distance = sorted_loc2[i] - sorted_loc1[i]
    abs_distance = abs(distance)
    final_distance += abs_distance
    
print(final_distance)