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

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

verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Mahdiar Naghizadeh (۱ سال پیش)
descriptionsolution.py ۱۰ خط • ۲۲۱ بایت
1n = int(input())
2houses = list(map(int, input().split()))
3l = 0
4
5for i in range(1, n + 1):
6 first = houses.index(i)
7 second = houses.index(i, first + 1)
8 l += abs(second - first)
9
10print(l)
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8