codeforce - ropewalker

jakaria_hossain Jun 21st, 2019 59 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
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