fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int complect(int & b, int & a) {
  6. int com = min(a, b);
  7. a -= com;
  8. b -= com;
  9. return com;
  10. }
  11. int main() {
  12. int a1, a2, a3, b1, b2, b3, c; //c-все возможные комплекты
  13. cin >> a1 >> a2 >> a3 >> b1 >> b2 >> b3;
  14. c = 0;
  15. c += complect(a1, b1);
  16. c += complect(a2, b2);
  17. c += complect(b1, a3);
  18. c += complect(a1, b3);
  19. c += complect(a2, b3);
  20. c += complect(a3, b3);
  21. c += complect(b1, a3);
  22. c += complect(b2, a3);
  23.  
  24. cout << c;
  25. return 0;
  26. }
Success #stdin #stdout 0s 4744KB
stdin
4 2 0
1 3 6
stdout
6