-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneps261.cpp
More file actions
50 lines (36 loc) · 712 Bytes
/
Copy pathneps261.cpp
File metadata and controls
50 lines (36 loc) · 712 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* Contest : NEPS
* Problem : 261 - Ogros
* Link : https://neps.academy/br/exercise/261
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int n, k, x;
vector<int> v(112345), p(112345);
int bs(int x) {
int l = 0, r = n - 1, m, ans = -1;
while (l <= r) {
int m = l + (r - l) / 2;
if (v[m] <= x) {
ans = p[m];
l = m + 1;
} else
r = m - 1;
}
return ans;
}
int main() {
fastio
cin >> n >> k;
for (int i = 1; i < n; i++) cin >> v[i];
v[0] = 1;
for (int i = 0; i < n; i++) cin >> p[i];
while (k--) {
cin >> x;
cout << bs(x) << " ";
}
cout << "\n";
return 0;
}