304 North Cardinal St.
Dorchester Center, MA 02124

# Minimum Distance CodeChef Solution

## Minimum Distance CodeChef Solution in C++14

``````#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"

void solve()
{
long double a, b, c;
cin >> a >> b >> c;
if (a < b)
swap(a, b);
cout << setprecision(6);
if (a + b <= c)
{
cout << c - a - b << endl;
}
else
{
if (a - b <= c)
cout << "0\n";
else
cout << a - b - c << endl;
}
}

signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tCase;
cin >> tCase;
while (tCase--)
{
solve();
}

return 0;
}``````

## Minimum Distance CodeChef Solution in PYTH 3

``````# cook your dish here
t = int(input())
for i in range(t):
d1, d2, d3 = map(int, input().split())
print(max(0, d3 - d1 - d2, d1 - d3 - d2, d2 - d3 - d1))``````

## Minimum Distance CodeChef Solution in C

``````#include <stdio.h>
int main()
{
int t; scanf("%d",&t);
while(t--)
{
int a,b,d,ans; scanf("%d %d %d",&a,&b,&d);
if(a < b) { a^=b; b^=a; a^=b; }
if(d > a+b) printf("%d\n",d-a-b);
else if(d < a-b) printf("%d\n",a-b-d);
else printf("0\n");
}
return 0;
}``````

## Minimum Distance CodeChef Solution in JAVA

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int j=0;j<t;j++){
int ds=sc.nextInt();
int dt=sc.nextInt();
int d=sc.nextInt();
System.out.println(Math.max(Math.max(Math.max(0, d - ds - dt),ds - dt - d), dt - ds - d));
}
}
}``````

## Minimum Distance CodeChef Solution in PYPY 3

``````
def integer_list():
return list(map(int, input().split()))

def main():

if ds + dt < d:
print(d - ds -dt )
elif ds > d + dt:
print(ds - d - dt)
elif dt > d + ds:
print(dt - d - ds)
else:
print(0)

t = int(input())

for _ in range(t):
ds, dt, d = integer_list()
main()``````

## Minimum Distance CodeChef Solution in PYTH

``````t = int(raw_input())
for i in range(t):
st = raw_input().split()
DS = int(st[0])
DT = int(st[1])
D = int(st[2])
L = [D,DS,DT]
L.sort()
r = L[2]-L[1]-L[0]
if r < 0:
r = 0
# endif
print r
# endfor i

``````

## Minimum Distance CodeChef Solution in C#

``````using System;

namespace CC_E_MinimumDistance
{
class MainClass
{
public static void Main(string[] args)
{
int[] result = new int[terms];

for (int i = 0; i < terms; i++)
{

Array.Sort(data);

int dMin = data[2] - (data[0] + data[1]);

if (dMin <= 0)
{
result[i] = 0;
}
else
{
result[i] = dMin;
}
}

foreach (int minDistance in result)
{
Console.WriteLine(minDistance);
}

}
}
}``````
##### Minimum Distance CodeChef Solution Review:

In our experience, we suggest you solve this Minimum Distance CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Minimum Distance CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Minimum Distance CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!