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

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

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