11571 | 2024-10-27 08:23:59 | chucknorris | Pontos Átlag | cpp17 | Accepted 100/100 | 46ms | 1260 KiB |
// NOTE: it is recommended to use this even if you don't understand the following code.
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
// uncomment the two following lines if you want to read/write from files
// ifstream cin("input.txt");
// ofstream cout("output.txt");
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K;
cin >> N >> K;
vector<int> P(N);
for (int i = 0; i < N; ++i)
cin >> P[i];
int ans = 0;
long long S = 0;
for (int i = 0; i < N; ++i) S = S + P[i];
if(S == 1LL * K * N) cout << 0;
else if(S < 1LL * K * N) cout << 1;///eleg csak 1-et annyival emelni, hogy meglegyen a kert atlag
else{
sort(P.begin(), P.end());
///a legnagybbat csokkentjuk
for(int i = N - 1; i >= 0 and S > 1LL * K * N; i--){
if(S - P[i] + 1 > 1LL * K * N){
ans = ans + 1; S = S - P[i] + 1;
}
else{
ans = ans + 1; S = 0;
}
}
cout << ans << endl;
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 500 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 1ms | 320 KiB | ||||
4 | Accepted | 1ms | 320 KiB | ||||
5 | Accepted | 1ms | 320 KiB | ||||
6 | Accepted | 1ms | 320 KiB | ||||
7 | Accepted | 1ms | 320 KiB | ||||
8 | Accepted | 1ms | 320 KiB | ||||
9 | Accepted | 1ms | 544 KiB | ||||
10 | Accepted | 1ms | 320 KiB | ||||
11 | Accepted | 1ms | 320 KiB | ||||
12 | Accepted | 1ms | 320 KiB | ||||
13 | Accepted | 1ms | 320 KiB | ||||
subtask3 | 40/40 | ||||||
14 | Accepted | 1ms | 320 KiB | ||||
15 | Accepted | 1ms | 320 KiB | ||||
16 | Accepted | 1ms | 508 KiB | ||||
17 | Accepted | 1ms | 320 KiB | ||||
18 | Accepted | 1ms | 376 KiB | ||||
19 | Accepted | 1ms | 432 KiB | ||||
20 | Accepted | 1ms | 332 KiB | ||||
21 | Accepted | 1ms | 320 KiB | ||||
22 | Accepted | 1ms | 320 KiB | ||||
23 | Accepted | 1ms | 560 KiB | ||||
24 | Accepted | 1ms | 320 KiB | ||||
25 | Accepted | 1ms | 320 KiB | ||||
26 | Accepted | 1ms | 320 KiB | ||||
subtask4 | 40/40 | ||||||
27 | Accepted | 25ms | 1080 KiB | ||||
28 | Accepted | 46ms | 1220 KiB | ||||
29 | Accepted | 46ms | 1080 KiB | ||||
30 | Accepted | 46ms | 1084 KiB | ||||
31 | Accepted | 46ms | 1220 KiB | ||||
32 | Accepted | 46ms | 1168 KiB | ||||
33 | Accepted | 46ms | 1080 KiB | ||||
34 | Accepted | 46ms | 1084 KiB | ||||
35 | Accepted | 46ms | 1080 KiB | ||||
36 | Accepted | 30ms | 1224 KiB | ||||
37 | Accepted | 25ms | 1080 KiB | ||||
38 | Accepted | 21ms | 1228 KiB | ||||
39 | Accepted | 45ms | 1080 KiB | ||||
40 | Accepted | 45ms | 1080 KiB | ||||
41 | Accepted | 35ms | 1216 KiB | ||||
42 | Accepted | 45ms | 1228 KiB | ||||
43 | Accepted | 32ms | 1260 KiB |