This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST_IO cin.tie(nullptr); ios_base::sync_with_stdio(0)
int main()
{
FAST_IO;
int n, a, b, current=0, maxi=0, ans=1e7;
cin>>n>>a>>b;
vector<int> numbers;
for (int i=0; i<n; i++){
int a;
cin>>a;
numbers.push_back(a);
}
sort(numbers.begin(), numbers.end());
maxi=numbers[n-1];
current=numbers[0];
for (int i=1; i<n; i++){
if (i>=a && i<=b) {
if (numbers[i]!=numbers[i-1]) {
ans=min(abs(numbers[i]-maxi), abs(numbers[i]-current));
}
}
}
for (int i=n-2; i>=0; i--){
if (i>=a && i<=b) {
if (numbers[i]!=numbers[i+1]) {
ans=min(abs(numbers[i]-maxi), abs(numbers[i]-current));
}
}
}
cout<<ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |