Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define int int64_t
- using namespace std;
- void solve(){
- int D;
- cin >> D;
- int A_p, B_p, A_f, B_f;
- cin >> A_p >> B_p >> A_f >> B_f;
- if(D == 1){
- if(max(A_p, max(A_f, max(B_p, B_f))) < abs((A_p - A_f) - (B_p - B_f)))
- cout << abs((A_p - A_f) - (B_p - B_f));
- else
- cout << -1;
- }
- else{
- if(max(A_p, max(A_f, max(B_p, B_f))) < abs((A_p - A_f) + (B_p - B_f)))
- cout << abs((A_p - A_f) + (B_p - B_f));
- else
- cout << -1;
- }
- }
- int32_t main() {
- int test_case = 1;
- //cin >> test_case;
- while(test_case--)
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment