91122024-02-14 16:28:43111Pontos Átlagcpp17Accepted 100/10052ms8408 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef CB
	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	int N, K;
	cin >> N >> K;
	deque<int> v(N);
	int s = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		s += v[i];
	}
	if (s < N * K) {
		cout << 1 << '\n';
		return 0;
	}
	sort(v.begin(), v.end());
	int ans = 0;
	while (s > N * K) {
		s -= v.back() - 1;
		v.pop_back();
		ans++;
	}
	cout << ans << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Accepted3ms2064 KiB
subtask220/20
3Accepted3ms2272 KiB
4Accepted2ms2356 KiB
5Accepted3ms2444 KiB
6Accepted3ms2656 KiB
7Accepted3ms2868 KiB
8Accepted2ms2948 KiB
9Accepted3ms3080 KiB
10Accepted3ms3288 KiB
11Accepted2ms3380 KiB
12Accepted3ms3500 KiB
13Accepted2ms3496 KiB
subtask340/40
14Accepted3ms3404 KiB
15Accepted3ms3524 KiB
16Accepted3ms3600 KiB
17Accepted3ms3600 KiB
18Accepted3ms3600 KiB
19Accepted3ms3596 KiB
20Accepted3ms3752 KiB
21Accepted3ms3704 KiB
22Accepted3ms3836 KiB
23Accepted3ms3712 KiB
24Accepted3ms3596 KiB
25Accepted3ms3600 KiB
26Accepted3ms3688 KiB
subtask440/40
27Accepted27ms6604 KiB
28Accepted50ms6888 KiB
29Accepted50ms7016 KiB
30Accepted50ms6760 KiB
31Accepted52ms7020 KiB
32Accepted50ms7420 KiB
33Accepted52ms7396 KiB
34Accepted52ms7592 KiB
35Accepted50ms7676 KiB
36Accepted35ms7800 KiB
37Accepted50ms7472 KiB
38Accepted26ms8012 KiB
39Accepted50ms8160 KiB
40Accepted48ms8288 KiB
41Accepted39ms8288 KiB
42Accepted48ms8288 KiB
43Accepted37ms8408 KiB