36 lines
561 B
C++
36 lines
561 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
const int MAX_N = 1e6;
|
|
int a[MAX_N];
|
|
|
|
int main() {
|
|
freopen("muasam.inp", "r", stdin);
|
|
freopen("muasam.out", "w", stdout);
|
|
|
|
ios::sync_with_stdio(false);
|
|
cin.tie(nullptr);
|
|
|
|
int n, l, r;
|
|
cin >> n >> l >> r;
|
|
for (int i = 0; i < n; i++)
|
|
cin >> a[i];
|
|
int res = 1e9;
|
|
|
|
sort(a, a + n);
|
|
int L = 0, R = n - 1;
|
|
while (L < R) {
|
|
int sum = a[L] + a[R];
|
|
if (sum > r)
|
|
R--;
|
|
else if (sum < l)
|
|
L++;
|
|
else {
|
|
res = min(res, sum);
|
|
R--;
|
|
}
|
|
}
|
|
cout << res << '\n';
|
|
}
|