Team Formation



#include <stdio.h>

#include <stdlib.h>

int main()

{

    long int r,n,m,i,k,c=0;

    scanf("%ld%ld%ld",&n,&m,&k);

    r=(n<=m&&n<=k)?n:(m<=n&&m<=k)?m:k;

    c+=r;

    n-=r;

    m-=r;

    k-=r;

    while((n>1||m>1)&&n>0&&m>0){

        if(n>=m){

            n-=2;

            m--;

            c++;

        }

        else if(n<=m){

            m-=2;

            n--;

            c++;

        }

    }

    printf("%ld",c);

}


Post a Comment

0 Comments