OFFSIDE - He is offside! Editorial SPOJ - UCS - Unleash-Coding-Skills

## Thursday, 3 May 2018

The link for the problem OFFSIDE - He is offside! is:

http://www.spoj.com/problems/OFFSIDE/

The solution to the problem is quite simple.You must simple sort the Cj array and take the value of the second least element. Compare with the Bi array elements if any element if Bi array is less than 2nd min element in Cj array. Then you must stop there and must print "Y" otherwise you must print "N".

The CPP solution for  OFFSIDE - He is offside!  problem is:

```#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
vector<long int >b;
vector<long int>c;
long int p,q,i,j,k;
scanf("%ld",&p);
scanf("%ld",&q);
while(p!=0&&q!=0)
{
b.clear();
c.clear();
for(i=0;i<p;i++)
{
scanf("%ld",&j);
b.push_back(j);
}
for(i=0;i<q;i++)
{
scanf("%ld",&j);
c.push_back(j);
}
sort(c.begin(),c.end());
int fl=0;
long int r=c[1];
for(i=0;i<b.size();i++)
{
if(b[i]<r)
{
fl=1;
break;
}
}
if(fl==1)
{
printf("Y\n");
}
else
{
printf("N\n");
}
scanf("%ld",&p);
scanf("%ld",&q);
}
return 0;
}```

Happy Coding.................