Math, asked by amankoli9004, 11 months ago

After governor's attack on prison, rick found himself surrounded by walkers. They are coming towards him from all sides. Now, suppose rick have infinite number of bullets with him. Suppose rick need 1 bullet to kill each walker (yeah he is good in killing walkers). Now as soon as he kills 1 walker rest of the walkers move forward by 1 m. There are n walkers each at some distance from rick.

Answers

Answered by lastdragonstone
0

Answer:

#include <iostream>

using namespace std;

int main() {

int num,w;

cin >> num;          // Reading input from STDIN

//cout << "Input number is " << num << endl;  // Writing output to STDOUT

for(int i=0;i<num;i++)

{

    cin>>w;

    int a[w];

    int min=0;

    int flag=0;

    for(int j=0;j<w;j++)

    {

        cin>>a[j];

    }

    for(int k=0;k<w;k++)

    {

        a[k]=a[k]-min;

        if(a[k]!=0)

        {

            a[k]=0;

        }

        else

        {

            cout<<"\nGoodbye Rick"<<endl;

            flag=k;

            break;

        }

        min++;

        if(k%6==0)

       min++;

    }

    if(a[w-1]==0)

    {

     cout<<"\nRick now go and save Carl and Judas";  

    }

    else{

     cout<<w-min<<endl;

    }

}

}

Step-by-step explanation:

Similar questions