You are viewing a single comment's thread. Return to all comments →
#include <bits/stdc++.h> using namespace std; void miniMaxSum(vector<int> arr) { sort(arr.begin(), arr.end()); long long minSum = accumulate(arr.begin(), arr.begin() + 4, 0LL); long long maxSum = accumulate(arr.end() - 4, arr.end(), 0LL); cout << minSum << " " << maxSum << endl; } int main() { vector<int> arr(5); for (int i = 0; i < 5; i++) cin >> arr[i]; miniMaxSum(arr); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →