SPOJ - He is Offside Problem Solution without sorting
Solution:-
using namespace std;
int attacker,defender,goalie;
int main()
{
int a,d;
while(1)
{
attacker=defender=goalie=INT_MAX;
cin>>a>>d;
if(a==0 && d==0)
break;
int temp;
for(int i=0;i<a;i++)
{
cin>>temp;
if(temp<attacker)
attacker=temp;
}
for(int i=0;i<d;i++)
{
cin>>temp;
if(temp<goalie)
{
defender=goalie;
goalie=temp;
}
else if(temp<defender)
defender=temp;
}
if(defender>attacker)
cout<<"Y\n";
else
cout<<"N\n";
}
return 0;
}
No comments:
Post a Comment