Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- //freopen("10611.txt","r",stdin);
- vector<long long int>sa;
- vector<long long int>::iterator up,down;
- int x,a;
- scanf("%d",&x);
- while(x--){
- scanf("%d",&a);
- sa.push_back(a);
- }
- scanf("%d",&x);
- while(x--){
- scanf("%d",&a);
- up=upper_bound(sa.begin(),sa.end(),a);
- down=lower_bound(sa.begin(),sa.end(),a);
- if((down-sa.begin()-1)<0) printf("X ");
- else printf("%d ",sa[down-sa.begin()-1]);
- if(up==sa.end()) printf("X\n");
- else printf("%d\n",sa[(up-sa.begin())]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement