fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int min(vector<int>& inputs, int offset, int len)
  6. {
  7. int min = 2000;
  8. vector<int>::iterator i = inputs.begin() + offset;
  9. for (vector<int>::iterator it = i; it - i < len; it++) {
  10. if (*it < min)
  11. min = *it;
  12. }
  13. return min;
  14. }
  15.  
  16. int main(void)
  17. {
  18. vector<int> inputs(5);
  19. for (int i=0; i<5; i++)
  20. cin >> inputs[i];
  21.  
  22. int pasta_min = min(inputs, 0, 3);
  23. int juice_min = min(inputs, 3, 2);
  24.  
  25. cout << pasta_min + juice_min - 50 << endl;
  26. }
  27.  
Success #stdin #stdout 0s 3476KB
stdin
800
700
900
198
330 
stdout
848