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

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

code_blocks
مسئله مربوطه: رستگاری آرتور (#1) arrow_outward
verified
وضعیت داوری نهایی: پذیرفته شد
terminal
زبان برنامه‌نویسی: C++
schedule
ارسال‌کننده و زمان:
Kiarash Hamini (۲ سال پیش)
descriptionsolution.cpp ۲۶ خط • ۳۸۲ بایت
1#include <iostream>
2#include <cmath>
3using namespace std;
4
5int main()
6{
7 int n;
8 cin >> n;
9 int arr[n];
10
11 for (int i = 0; i < n; i++)
12 {
13 cin >> arr[i];
14 }
15
16 long long int cnt = 0;
17 for (int i = 0; i < n / 2; i++)
18 {
19 int j = n - 1 - i;
20 cnt += abs(arr[i] - arr[j]);
21 }
22
23 cout << cnt;
24
25 return 0;
26}
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8