This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*input
5 2 4
1
3
3
1
4
*/
#include <bits/stdc++.h>
using namespace std;
namespace my_template {
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;
#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494L;
template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
template<typename T>
void print(vector<T> vec, string name = "") {
	cout << name;
	for (auto u : vec)
		cout << u << ' ';
	cout << '\n';
}
}
using namespace my_template;
const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
int N, A, B;
vi sk;
int gali(int diff) {
	vi dp(N + 3, 0);
	dp[0] = 1;
	int j = 1;
	for (int i = 0; i < N; ++i)
	{
		if (i > 1) dp[i] += dp[i - 1];
		if (dp[i] <= 0) continue;
		j = max(j, i + 1);
		while (j + 1 <= N and sk[j + 1] - sk[i + 1] <= diff) j++;
		// printf("i = %d, j = %d, dp = %d, A = %d, B = %d, rib = %d %d\n", i, j, dp[i], A, B, i + A, min(i + B, j));
		if (i + A <= min(i + B, j)) {
			dp[i + A]++;
			dp[min(i + B, j) + 1]--;
		}
	}
	dp[N] += dp[N - 1];
	return dp[N] > 0;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #ifndef LOCAL
// 	freopen("lmio_2018_3e2_plaukimo_varzybos_vyr.in", "r", stdin);
// 	freopen("lmio_2018_3e2_plaukimo_varzybos_vyr.out", "w", stdout);
// #endif
	cin >> N >> A >> B;
	sk = vi(N + 1);
	for (int i = 1; i <= N; ++i)
		cin >> sk[i];
	sort(sk.begin() + 1, sk.end());
	int l = 0;
	int h = 1e8;
	int m;
	while (l < h) {
		m = (l + h) / 2;
		// printf("m = %d, gali = %d\n", m, gali(m));
		if (gali(m))
			h = m;
		else
			l = m + 1;
	}
	printf("%d\n", l);
}
/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/
| # | 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... |