6710 | 2023-12-17 18:20:00 | MagyarKendeSZLG | Pontos Átlag | cpp17 | Wrong answer 0/100 | 46ms | 5944 KiB |
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K, sum;
cin >> N >> K;
vector<int> P(N);
for (int i = 0; i < N; i++) {
cin >> P[i];
sum += P[i];
}
const int prod = N * K;
if (prod == sum) {
cout << 0 << endl;
} else if (prod > sum || N == 1) {
cout << 1 << endl;
} else if (N == 2) {
if (K > max(P[0], P[1]) + 1e6 || K < min(P[0], P[1]) + 1) {
cout << 2 << endl;
} else {
cout << 1 << endl;
}
} else {
sort(P.begin(), P.end());
for (int i = N - 1, result = 0; i >= 0; i--) {
sum -= P[i] - 1;
result++;
if (prod >= sum) {
cout << result << endl;
return 0;
}
}
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2164 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 3ms | 2400 KiB | ||||
4 | Accepted | 3ms | 2396 KiB | ||||
5 | Wrong answer | 3ms | 2392 KiB | ||||
6 | Accepted | 3ms | 2392 KiB | ||||
7 | Accepted | 3ms | 2612 KiB | ||||
8 | Accepted | 3ms | 2732 KiB | ||||
9 | Wrong answer | 3ms | 2940 KiB | ||||
10 | Wrong answer | 3ms | 3152 KiB | ||||
11 | Accepted | 3ms | 3364 KiB | ||||
12 | Accepted | 3ms | 3580 KiB | ||||
13 | Wrong answer | 3ms | 3948 KiB | ||||
subtask3 | 0/40 | ||||||
14 | Accepted | 3ms | 4056 KiB | ||||
15 | Accepted | 3ms | 4040 KiB | ||||
16 | Accepted | 3ms | 4268 KiB | ||||
17 | Accepted | 3ms | 4132 KiB | ||||
18 | Accepted | 3ms | 4128 KiB | ||||
19 | Accepted | 3ms | 4104 KiB | ||||
20 | Wrong answer | 3ms | 4104 KiB | ||||
21 | Wrong answer | 3ms | 4004 KiB | ||||
22 | Accepted | 3ms | 4012 KiB | ||||
23 | Accepted | 3ms | 4016 KiB | ||||
24 | Wrong answer | 3ms | 4012 KiB | ||||
25 | Accepted | 3ms | 4020 KiB | ||||
26 | Wrong answer | 3ms | 4088 KiB | ||||
subtask4 | 0/40 | ||||||
27 | Wrong answer | 45ms | 5516 KiB | ||||
28 | Partially correct | 46ms | 5424 KiB | ||||
29 | Wrong answer | 25ms | 5652 KiB | ||||
30 | Partially correct | 45ms | 5428 KiB | ||||
31 | Partially correct | 45ms | 5492 KiB | ||||
32 | Partially correct | 45ms | 5428 KiB | ||||
33 | Wrong answer | 26ms | 5560 KiB | ||||
34 | Partially correct | 46ms | 5692 KiB | ||||
35 | Partially correct | 45ms | 5684 KiB | ||||
36 | Wrong answer | 27ms | 5832 KiB | ||||
37 | Wrong answer | 45ms | 5776 KiB | ||||
38 | Accepted | 24ms | 5900 KiB | ||||
39 | Accepted | 43ms | 5704 KiB | ||||
40 | Wrong answer | 43ms | 5684 KiB | ||||
41 | Accepted | 35ms | 5944 KiB | ||||
42 | Wrong answer | 43ms | 5900 KiB | ||||
43 | Wrong answer | 34ms | 5900 KiB |