fork download
  1. // In the name of Allah, the most gracious, the most merciful
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define nl "\n"
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. long long a, b, c;
  10. cin >> a >> b >> c;
  11. if (a == 0 || b == 0 || c == 0)
  12. {
  13. cout << 0 << nl;
  14. return 0;
  15. }
  16. long long minNum = min(min(a, b), c);
  17. if (minNum == a || minNum == c)
  18. {
  19. cout << minNum << nl;
  20. return 0;
  21. }
  22. a -= minNum;
  23. c -= minNum;
  24. int temp = 0, result = 0;
  25. for (int i = 1; i <= c; i++)
  26. {
  27. temp = i * 2;
  28. if (temp > a)
  29. {
  30. result = -1 + i;
  31. break;
  32. }
  33. else
  34. {
  35. result = i;
  36. }
  37. }
  38. result += minNum;
  39. cout << result;
  40. return 0;
  41. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
0