ProgMe

Untitled

Feb 13th, 2021
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define int int64_t
  4.  
  5. using namespace std;
  6.  
  7. void solve(){
  8. int D;
  9. cin >> D;
  10. int A_p, B_p, A_f, B_f;
  11. cin >> A_p >> B_p >> A_f >> B_f;
  12. if(D == 1){
  13. if(max(A_p, max(A_f, max(B_p, B_f))) < abs((A_p - A_f) - (B_p - B_f)))
  14. cout << abs((A_p - A_f) - (B_p - B_f));
  15. else
  16. cout << -1;
  17. }
  18. else{
  19. if(max(A_p, max(A_f, max(B_p, B_f))) < abs((A_p - A_f) + (B_p - B_f)))
  20. cout << abs((A_p - A_f) + (B_p - B_f));
  21. else
  22. cout << -1;
  23. }
  24. }
  25.  
  26. int32_t main() {
  27. int test_case = 1;
  28. //cin >> test_case;
  29. while(test_case--)
  30. solve();
  31. }
Advertisement
Add Comment
Please, Sign In to add comment