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

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

verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Baran Kosari (۳ سال پیش)
descriptionsolution.py ۱۳ خط • ۲۳۷ بایت
1n=int(input())
2a=list(map(int,input().split()))
3ch=[0]*n
4cj=[0]*n
5for i in range(0,len(a)) :
6 if ch[a[i]-1]==0 :
7 ch[a[i]-1]=i
8 else :
9 cj[a[i]-1]=i
10o=0
11for i in range(n) :
12 o+=abs(cj[i]-ch[i])
13print(o)
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8