-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathb.cc
More file actions
32 lines (32 loc) · 670 Bytes
/
b.cc
File metadata and controls
32 lines (32 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// https://codeforces.com/contest/1148/problem/B
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
ll n, m, ta, tb, k;
cin >> n >> m >> ta >> tb >> k;
vi a(n), b(m);
if (n <= k || m <= k) {
cout << "-1\n";
return 0;
}
for (ll i = 0; i < n; i++) {
cin >> a[i];
a[i] += ta;
}
for (ll i = 0; i < m; i++)
cin >> b[i];
ll M = 0, j = 0;
for (ll i = 0; i <= k; i++) {
while (j < m && a[i] > b[j]) j++;
if (j + k - i >= m || a[i] > b[j]) {
M = -1;
break;
}
M = max(M, b[j + k - i] + tb);
}
cout << M << "\n";
}