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

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

code_blocks
مسئله مربوطه: رستگاری آرتور (#1) arrow_outward
verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Parsa Alizadeh (۳ سال پیش)
descriptionsolution.py ۱۴ خط • ۲۸۱ بایت
1n=int(input())
2arr1=list(map(int,input().split()))
3counter=0
4x=0
5if(n%2==0):
6 x=int(n/2)-1
7else:
8 x=int(n/2)-1
9for i in range(0,x+1,1):
10 if arr1[i]>arr1[n-1-i]:
11 counter+=arr1[i]-arr1[n-1-i]
12 else:
13 counter+=arr1[n-1-i]-arr1[i]
14print(counter)
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8