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 <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
int n, a, b;
cin >> n >> a >> b;
int t[40];
for(int i = 0; i < n; i++) cin >> t[i];
sort(t, t+n);
int ans = -1;
// bruteforce
// subt #1 states a == b
ll mn = 1e6+1;
ll mx = -1;
int track = 0;
for(int i = 0; i < n; i++)
{
track++;
if(track == 1) mn = t[i];
if(track == a)
{
mx = t[i];
ans = max((ll)ans, mx-mn);
track = 0;
}
}
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... |