Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <string>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- void co(vector <int> v){
- for (auto x: v) cout<<x<<'\n';
- cout<<'\n';
- }
- vector <int> A(1);
- void bp(int x){
- int R = A.size();
- int L = 0;
- while (R - L > 1){
- int M = (R + L ) / 2;
- if (A[M] > x){
- R = M;
- }else{
- L = M;
- }
- }
- //cout<<A[L] <<' '<<A[R]<<'\n';
- if (abs(x - A[L]) <= abs(x - A[R])){
- cout<<A[L]<<'\n';
- }
- else cout<<A[R]<<'\n';
- }
- int main()
- {
- int n,k;
- cin>>n>>k;
- A.resize(n);
- for (int &x: A) cin>>x;
- vector <int> B(k);
- for (int &x: B) cin>>x;
- for (int x: B){
- bp(x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement