Accepted solution

599A - Patrick and Shopping

Open original problem
Source code

#include<stdio.h>

int small(int a,int b)

{

    if(a>b)

    {

        return b;

    }

    else return a;

}

int main()

{

    int d1,d2,d3;

    int dist1=0,dist2=0,dist3=0,dist4=0;

    scanf("%d %d %d",&d1,&d2,&d3);

    dist1=d1+d2+d3;

    dist2=2*(d1+d2);

    dist3=d1+d3+d3+d1;

    dist4=d2+d3+d3+d2;

    int dist= small(dist1,small(dist2,small(dist3,dist4)));

    printf("%d",dist);

}
Join the discussion

Add your comment