... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Monday, January 6, 2014

LOJ-1088 :: Points in Segments

//Problem link>>http://lightoj.com/volume_showproblem.php?problem=1088


#include <bits/stdc++.h>
using namespace std ;
int main ()
{
    int t , it , i ,n ,q ,a[100005] ,x ,y ,low ,up ;

     scanf ("%d",&t) ;
    for (it=1 ; it<=t ; it++)
    {
       scanf ("%d %d",&n , &q) ;
        for (i=0 ; i<n ; i++) scanf ("%d",&a[i]) ;

       printf ("Case %d:\n",it) ;
        for (i=1 ; i<=q ; i++)
        {
            scanf ("%d %d",&x,&y) ;
            low=lower_bound(a, a+n ,x)-a ;
            up=upper_bound(a, a+n ,y)-a ;
            int ans=up-low ;

           printf ("%d\n",ans) ;

        }

    }

    return 0 ;
}

No comments:

Post a Comment