Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- long long int n,q,i,j,a[50009];
- long long int x,min,max;
- scanf("%lld",&n);
- for(i=1;i<=n;i++){
- scanf("%lld",&a[i]);
- }
- scanf("%lld",&q);
- for(i=1;i<=q;i++){
- scanf("%lld",&x);
- min=999999999;
- max=0;
- for(j=1;j<=n;j++){
- if(a[j]>max && a[j]<x)
- max=a[j];
- if(a[j]<min && a[j]>x)
- min=a[j];
- }
- if(max==0 && min==999999999)
- printf("X X\n");
- else{
- if(max!=0 && min==999999999)
- printf("%lld X\n",max);
- else if(max==0 && min!=999999999)
- printf("X %lld\n",min);
- else
- printf("%lld %lld\n",max,min);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement