arrow_forward همه ارسال‌ها

جزئیات ارسال کد#747

verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Mahdiar Naghizadeh (۱ سال پیش)
descriptionsolution.py ۱۳ خط • ۲۴۹ بایت
1n = int(input())
2houses = list(map(int, input().split()))
3
4position = {}
5total = 0
6
7for i, j in enumerate(houses, start=1):
8 if j not in position:
9 position[j] = i
10 else:
11 total += abs(i - position[j])
12
13print(total)
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8