6715 | 2023-12-17 18:33:25 | MagyarKendeSZLG | Pontos Átlag | cpp17 | Wrong answer 0/100 | 46ms | 5840 KiB |
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
const int LIM = 1e6;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, K, sum = 0;
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;
sort(P.begin(), P.end());
if (prod == sum) {
cout << 0 << endl;
} else if (N == 1) {
cout << 1 << endl;
} else if (N == 2) {
if (prod > max(P[0], P[1]) + LIM || prod < min(P[0], P[1]) + 1) {
cout << 2 << endl;
} else {
cout << 1 << endl;
}
} else if (prod > sum) {
for (int i = 0, result = 0; i < N; i++) {
sum += LIM - P[i];
result++;
if (prod <= sum) {
cout << result << endl;
return 0;
}
}
} else {
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 | 1700 KiB | ||||
2 | Accepted | 3ms | 1860 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 3ms | 2076 KiB | ||||
4 | Wrong answer | 3ms | 2288 KiB | ||||
5 | Accepted | 3ms | 2376 KiB | ||||
6 | Accepted | 3ms | 2376 KiB | ||||
7 | Accepted | 3ms | 2496 KiB | ||||
8 | Accepted | 3ms | 2584 KiB | ||||
9 | Accepted | 3ms | 2584 KiB | ||||
10 | Accepted | 3ms | 2984 KiB | ||||
11 | Accepted | 3ms | 2948 KiB | ||||
12 | Accepted | 3ms | 3304 KiB | ||||
13 | Accepted | 3ms | 3432 KiB | ||||
subtask3 | 0/40 | ||||||
14 | Wrong answer | 3ms | 3492 KiB | ||||
15 | Accepted | 3ms | 3664 KiB | ||||
16 | Accepted | 3ms | 3596 KiB | ||||
17 | Accepted | 3ms | 3700 KiB | ||||
18 | Accepted | 3ms | 3672 KiB | ||||
19 | Accepted | 3ms | 3736 KiB | ||||
20 | Accepted | 3ms | 3824 KiB | ||||
21 | Accepted | 3ms | 3836 KiB | ||||
22 | Accepted | 3ms | 3732 KiB | ||||
23 | Accepted | 3ms | 3732 KiB | ||||
24 | Accepted | 3ms | 3736 KiB | ||||
25 | Accepted | 3ms | 3736 KiB | ||||
26 | Accepted | 3ms | 3740 KiB | ||||
subtask4 | 0/40 | ||||||
27 | Wrong answer | 46ms | 5064 KiB | ||||
28 | Partially correct | 46ms | 5212 KiB | ||||
29 | Partially correct | 45ms | 5392 KiB | ||||
30 | Partially correct | 46ms | 5456 KiB | ||||
31 | Partially correct | 45ms | 5456 KiB | ||||
32 | Partially correct | 46ms | 5460 KiB | ||||
33 | Partially correct | 46ms | 5460 KiB | ||||
34 | Partially correct | 46ms | 5524 KiB | ||||
35 | Partially correct | 46ms | 5588 KiB | ||||
36 | Wrong answer | 30ms | 5480 KiB | ||||
37 | Accepted | 46ms | 5484 KiB | ||||
38 | Accepted | 24ms | 5480 KiB | ||||
39 | Accepted | 43ms | 5732 KiB | ||||
40 | Accepted | 43ms | 5820 KiB | ||||
41 | Accepted | 35ms | 5828 KiB | ||||
42 | Accepted | 45ms | 5840 KiB | ||||
43 | Accepted | 34ms | 5836 KiB |