Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cmath>
  4. #include <algorithm>
  5. #include <set>
  6. #include <string>
  7.  
  8. #define ll long long
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. int n, a, b;
  15. cin >> n >> a >> b;
  16.  
  17. int ans = 0;
  18. if (n > max(a, b))
  19. {
  20. int x = min(a, b);
  21. int y = n - x;
  22. while (x >= 0 && y <= b)
  23. {
  24. ++ans, --x, ++y;
  25. }
  26. }
  27. else
  28. {
  29. int x = 0;
  30. int y = n;
  31. while (x <= a && y >= 0)
  32. {
  33. ++ans, ++x, --y;
  34. }
  35. }
  36.  
  37. cout << ans;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement