Code for USACO practice problems
cpp
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
364 B

3 years ago
#include <iostream>
using namespace std;
3 years ago
int a, b, x, y;
int main() {
cin >> a >> b >> x >> y;
3 years ago
int path1;
int path2;
int path3;
int ans;
path1 = abs(a - b);
path2 = abs(a - x) + abs(y - b);
path3 = abs(a - y) + abs(x - b);
3 years ago
ans = path1;
if (path2 < ans) {
ans = path2;
}
if (path3 < ans) {
ans = path3;
}
cout << ans << endl;
3 years ago
}