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

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

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