jakaria_hossain

codeforce - ropewalker

Jun 21st, 2019
104
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. long long ara[3],d,ans=0;
  6. cin>>ara[0]>>ara[1]>>ara[2]>>d;
  7. sort(ara,ara+3);
  8. if(ara[1]-ara[0]<d)ans+=d-(ara[1]-ara[0]);
  9. if(ara[2]-ara[1]<d)ans+=d-(ara[2]-ara[1]);
  10. cout<<ans<<endl;
  11. }
RAW Paste Data