Tuesday, 30 August 2016

Solution of URI 2167 :: Engine Failure


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
    int n, tmp = 0, RPM, cnt = 0, ans = 0, cndtn = 1;
    scanf("%d", &n);
    while(n--)
    {
        scanf("%d", &RPM);
        cnt++;
        if(RPM<tmp && cndtn==1)
        {
            ans = cnt;
            cndtn = 0;
        }
        tmp = RPM;
    }
    printf("%d\n", ans);
    return 0;
}

6 comments:

  1. I didn't undesrtand nothing!

    ReplyDelete
  2. #include
    int main()
    {
    int n,i,pos=0;

    scanf("%d",&n);
    int A[n];

    for(i=0;iA[i+1])
    {
    pos=i+2;
    break;
    }
    }
    printf("%d\n",pos);
    return 0;
    }
    //where is my problem? where is the 10% wrong?

    ReplyDelete
  3. in problem 2167
    i could understand this veriable ,,cndtn = 1;

    ReplyDelete
  4. #include

    int main()
    {
    int n,i,a=0;
    scanf("%d",&n);

    int arr[n*2];

    for(i=0;i<=n-1;i++)
    {
    scanf("%d",&arr[i]);
    }

    for(i=0;i<=n-1;i++)
    {
    if(arr[i]>arr[i+1])
    {
    a=i+1+1;
    break;
    }
    }

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

    return 0;
    }

    what is the problem

    ReplyDelete
  5. #include

    int main()
    {
    int n,i,a=0;
    scanf("%d",&n);

    int arr[n];

    for(i=0;i<=n-1;i++)
    {
    scanf("%d",&arr[i]);
    }

    for(i=0;i<=n-1;i++)
    {
    if(arr[i]>arr[i+1])
    {
    a=i+1+1;
    break;
    }
    }

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

    return 0;
    }


    what is the prblm with this one?

    ReplyDelete

Note: only a member of this blog may post a comment.