GPT答: |
7i24.cn
|
```cpp
#include <iostream>
#include <algorithm>
int main() {
int N, M;
std::cin >> N >> M;
int* candies = new int[N];
for (int i = 0; i < N; i++) {
std::cin >> candies[i];
}
std::sort(candies, candies + N);
int sum = 0;
for (int i = 0; i < N / M; i++) {
sum += candies[N - (i * M) - 1];
}
delete[] candies;
std::cout << sum << std::endl;
return 0;
}
```
|