You are viewing a single comment's thread. Return to all comments →
using namespace std; int main(){ long int n; cin >> n; long long int p = 0; int arr[n]; for(int i = 0; i < n; i++){ cin >> arr[i]; }
// Sort in descending order sort(arr, arr + n, greater<int>()); for(int i = 0; i < n; i++){ p += pow(2, i) * arr[i]; } cout << p; return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Marc's Cakewalk
You are viewing a single comment's thread. Return to all comments →
include
using namespace std; int main(){ long int n; cin >> n; long long int p = 0; int arr[n]; for(int i = 0; i < n; i++){ cin >> arr[i]; }
}