6536 | 2023-12-07 22:06:30 | TuruTamas | Pontos Átlag | cpp17 | Wrong answer 0/100 | 100ms | 8508 KiB |
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
ifstream in_file("minta/be1.txt");
#define input in_file
#else
#define input cin
#endif
typedef long long ll;
ll N, K, ossz;
ll P[200'000];
int main() {
input >> N >> K;
K *= N;
for (int n = 0; n < N; n++) {
input >> P[n];
ossz += P[n];
}
if (ossz == K) {
cout << 0 << endl;
exit(0);
}
if (N == 1) {
cout << 1 << endl;
exit(0);
}
if (N == 2) {
if (ossz > max(P[0], P[1])+1'000'000)
cout << 2 << endl;
else
cout << 1 << endl;
exit(0);
}
sort(P, P+N);
ll r = 0;
if (K > ossz) {
for (ll i = 0; i < N; i++) {
ossz += 1'000'000-P[i];
r++;
if (ossz >= K) {
cout << r << endl;
exit(0);
}
}
}
else {
for (ll i = N-1; i >= 0; i--) {
ossz -= P[i]-1;
r++;
if (ossz <= K) {
cout << r << endl;
exit(0);
}
}
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 2036 KiB | ||||
2 | Accepted | 3ms | 2052 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 3ms | 2264 KiB | ||||
4 | Accepted | 3ms | 2476 KiB | ||||
5 | Accepted | 3ms | 2808 KiB | ||||
6 | Accepted | 3ms | 2920 KiB | ||||
7 | Accepted | 3ms | 2984 KiB | ||||
8 | Wrong answer | 3ms | 2988 KiB | ||||
9 | Accepted | 3ms | 3116 KiB | ||||
10 | Accepted | 3ms | 3328 KiB | ||||
11 | Wrong answer | 3ms | 3432 KiB | ||||
12 | Wrong answer | 3ms | 3532 KiB | ||||
13 | Accepted | 3ms | 3540 KiB | ||||
subtask3 | 0/40 | ||||||
14 | Wrong answer | 3ms | 3632 KiB | ||||
15 | Accepted | 3ms | 3756 KiB | ||||
16 | Accepted | 3ms | 3840 KiB | ||||
17 | Accepted | 3ms | 4068 KiB | ||||
18 | Accepted | 3ms | 4076 KiB | ||||
19 | Accepted | 3ms | 4076 KiB | ||||
20 | Accepted | 3ms | 4108 KiB | ||||
21 | Accepted | 3ms | 4184 KiB | ||||
22 | Accepted | 3ms | 4192 KiB | ||||
23 | Accepted | 3ms | 4188 KiB | ||||
24 | Accepted | 3ms | 4192 KiB | ||||
25 | Accepted | 3ms | 4312 KiB | ||||
26 | Accepted | 3ms | 4396 KiB | ||||
subtask4 | 0/40 | ||||||
27 | Wrong answer | 90ms | 7516 KiB | ||||
28 | Accepted | 93ms | 7604 KiB | ||||
29 | Accepted | 90ms | 7600 KiB | ||||
30 | Accepted | 90ms | 7808 KiB | ||||
31 | Accepted | 90ms | 8024 KiB | ||||
32 | Accepted | 90ms | 7912 KiB | ||||
33 | Accepted | 90ms | 7904 KiB | ||||
34 | Accepted | 100ms | 7816 KiB | ||||
35 | Accepted | 92ms | 7908 KiB | ||||
36 | Accepted | 82ms | 7912 KiB | ||||
37 | Accepted | 71ms | 8116 KiB | ||||
38 | Accepted | 43ms | 8124 KiB | ||||
39 | Accepted | 87ms | 8116 KiB | ||||
40 | Accepted | 90ms | 8208 KiB | ||||
41 | Accepted | 67ms | 8296 KiB | ||||
42 | Accepted | 90ms | 8420 KiB | ||||
43 | Accepted | 64ms | 8508 KiB |