Minimum sum by choosing minimum of pairs from array | CPP program to minimize the cost of array minimization ; Returns minimum possible sum in array B [ ] ; driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; int minSum ( int A [ ] , int n ) { int min_val = * min_element ( A , A + n ) ; return ( min_val * ( n - 1 ) ) ; } int main ( ) { int A [ ] = { 3 , 6 , 2 , 8 , 7 , 5 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; cout << minSum ( A , n ) ; return 0 ; }