SHARE
TWEET

A

a guest Jun 19th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int wq[5],maxa,mini,mid,g,z,m,x1,x2,re=0;
  6.     scanf("%d %d %d %d",&wq[0],&wq[1],&wq[2],&z);
  7.     for(g=0,maxa=mini=wq[0];g<3;g++){
  8.         if(wq[g]>maxa)maxa=wq[g];
  9.         if(wq[g]<mini)mini=wq[g];
  10.     }
  11.     for(g=0,m=wq[0];g<3;g++)
  12.         if(wq[g]<maxa&&wq[g]>mini)m=wq[g];
  13.     x1=m+z, x2=m-z;
  14.     if(maxa<x1)re+=x1-maxa;
  15.     if(mini>x2)re+=mini-x2;
  16.     printf("%d\n",re);
  17.     return 0;
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top