0x00 Link
-
Source
-AtCoder
-
Tag
-芝士水题
-
Time
- ∗ * ∗
0x01 Source Code
//
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const int N = 2e5 + 6;
int a[N], b[N];
void solve() {
int n, m, d;
cin >> n >> m >> d;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
sort(a + 1, a + n + 1);
sort(b + 1, b + m + 1);
int i = n, j = m;
while (i >= 1 && j >= 1) {
if (abs(a[i] - b[j]) <= d) {
cout << a[i] + b[j] << endl;
return ;
}
if (a[i] >= b[j]) i--;
else j--;
}
cout << -1 << endl;
}
signed main() {
IOS
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
0x10 Diagram
-
404
0x11 Reference
-
404
作者 | 乐意奥AI