Advertisement
Alex_tz307

USACO 2019 February Contest, Bronze Problem 1. Sleepy Cow Herding

Dec 7th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. // http://usaco.org/index.php?page=viewproblem2&cpid=915
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("herding.in");
  7. ofstream fout("herding.out");
  8.  
  9. int main() {
  10.     vector<int> a(3);
  11.     for(int i = 0; i < 3; ++i)
  12.         fin >> a[i];
  13.     sort(a.begin(), a.end());
  14.     if(a[2] == a[0] + 2)
  15.         fout << "0\n";
  16.     else
  17.         if(a[1] == a[0] + 2 || a[2] == a[1] + 2)
  18.             fout << "1\n";
  19.     else
  20.         fout << "2\n";
  21.     fout << max(a[2] - a[1], a[1] - a[0]) - 1;
  22.  
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement