29 lines
447 B
C++
29 lines
447 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int a[1000000];
|
|
|
|
int main() {
|
|
ios::sync_with_stdio(false);
|
|
cin.tie(nullptr);
|
|
|
|
int m, n, S;
|
|
cin >> m >> n >> S;
|
|
for (int i = 0; i < m * n; i++)
|
|
cin >> a[i];
|
|
|
|
sort(a, a + m * n);
|
|
|
|
int l = 0, r = m * n - 1;
|
|
int cur_max = -1;
|
|
while (l < r) {
|
|
if (a[l] + a[r] > S)
|
|
r--;
|
|
else {
|
|
cur_max = max(cur_max, a[l] + a[r]);
|
|
l++;
|
|
}
|
|
}
|
|
cout << cur_max << '\n';
|
|
}
|