Saturday 30 April 2016

Solution of URI 1789 :: The Race of Slugs


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 a,b,c,max=0;
    while(scanf("%d",&a)!=EOF)
    {
        for(b=1,max=0; b<=a; b++)
        {
            scanf("%d", &c);
            if(c>max)
                max=c;
        }
        if(max<10)
            printf("1\n");
        else if(max<20)
            printf("2\n");
        else
            printf("3\n");
    }
    return 0;
}

2 comments:

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