fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int x1, x2, x3, c=0, r=0;
  6. cin >>x1 >>x2 >>x3;
  7. r =x1+x2+x3;
  8. r=r/3;
  9. if (x1<=r){
  10. x1=r-x1;
  11. }
  12. else {
  13. x1 = x1-r;
  14. }
  15. if (x2<=r){
  16. x2=r-x2;
  17. }
  18. else {
  19. x2 = x2-r;
  20. }
  21. if (x3<=r){
  22. x3=r-x3;
  23. }
  24. else {
  25. x3 = x3-r;
  26. }
  27. cout <<x1+x2+x3;
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5532KB
stdin
1 4 100
stdout
130