You are viewing a single comment's thread. Return to all comments →
Not even that complex:
int main() { int n, k; cin >> n >> k; vector<int> v(n); for(int i = 0; i < n; ++i) cin >> v[i]; sort(v.begin(), v.end()); reverse(v.begin(), v.end()); int tot = 0; for(int i = 0; i < n; ++i) { tot += ((i / k) + 1) * v[i]; } cout << tot << endl; return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Greedy Florist
You are viewing a single comment's thread. Return to all comments →
Not even that complex: