126742024-12-27 20:38:05sarminVásárlások inflációs hatása (75 pont)cpp17Accepted 75/751ms596 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {

	int n, k; cin >> n >> k;
	vector<long long> v(n);
	for (int i = 0; i < n; i++) cin >> v[i];
	sort(v.begin(), v.end());

	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = max(n - k, i + 1); j < n; j++) v[j] += v[i];
		ans += v[i];
	}
	cout << ans;
	
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms320 KiB
2Accepted0/01ms320 KiB
3Accepted1/11ms320 KiB
4Accepted1/11ms320 KiB
5Accepted1/11ms512 KiB
6Accepted1/11ms320 KiB
7Accepted1/11ms320 KiB
8Accepted1/11ms320 KiB
9Accepted1/11ms412 KiB
10Accepted1/11ms508 KiB
11Accepted2/21ms320 KiB
12Accepted5/51ms408 KiB
13Accepted5/51ms408 KiB
14Accepted5/51ms320 KiB
15Accepted5/51ms556 KiB
16Accepted5/51ms320 KiB
17Accepted5/51ms320 KiB
18Accepted5/51ms508 KiB
19Accepted5/51ms508 KiB
20Accepted5/51ms320 KiB
21Accepted5/51ms320 KiB
22Accepted5/51ms320 KiB
23Accepted5/51ms512 KiB
24Accepted5/51ms596 KiB