Friday 17 July 2015

ARMY


Army Strength

Link to the question :  ARMY

HINT :

The question may sound a little tricky or  difficult but actually its very simple. If you read it carefully, you will notice that all you need to do is sort both the armies and compare the last element of both the armies and then predict the result.

RECOMMENDED QUESTION :

Try your hands on this mathematical question.

SOURCE CODE :

#include<iostream>

#include<algorithm>

using namespace std;



int main()

{

    int t,ng,nm,i;

    cin>>t;

    cout<<endl;

    while(t--)

    {

        cin>>ng>>nm;

        int g[ng],m[nm];

        for(i=0;i<ng;i++)

            cin>>g[i];

        for(i=0;i<nm;i++)

            cin>>m[i];

        sort(g,g+ng);

        sort(m,m+nm);

        

            if(g[ng-1]>=m[nm-1])

            

                cout<<"Godzilla"<<endl;

                

            else

                cout<<"MechaGodzilla"<<endl;

        }
return 0;

}


2 comments:

  1. why sort when u can keep a track of highest element ?

    ReplyDelete
    Replies
    1. Yeah �� i dont know what i was thinking while solving this.��

      Delete