6537 | 2023-12-07 22:17:05 | TuruTamas | Pontos Átlag | cpp17 | Wrong answer 0/100 | 97ms | 7824 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) {
// cout << K << " " << P[0] << " " << P[1] << endl;
if (K > max(P[0], P[1])+1'000'000)
cout << 2 << endl;
else if (K < min(P[0], P[1])+1) {
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 | Accepted | 3ms | 1884 KiB | ||||
2 | Accepted | 3ms | 2072 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Accepted | 3ms | 2288 KiB | ||||
4 | Wrong answer | 3ms | 2628 KiB | ||||
5 | Accepted | 3ms | 2740 KiB | ||||
6 | Accepted | 3ms | 2944 KiB | ||||
7 | Accepted | 3ms | 3140 KiB | ||||
8 | Accepted | 3ms | 3212 KiB | ||||
9 | Accepted | 3ms | 3348 KiB | ||||
10 | Accepted | 3ms | 3560 KiB | ||||
11 | Accepted | 3ms | 3796 KiB | ||||
12 | Accepted | 3ms | 3796 KiB | ||||
13 | Accepted | 3ms | 3760 KiB | ||||
subtask3 | 0/40 | ||||||
14 | Wrong answer | 3ms | 3768 KiB | ||||
15 | Accepted | 3ms | 3916 KiB | ||||
16 | Accepted | 3ms | 3796 KiB | ||||
17 | Accepted | 3ms | 3948 KiB | ||||
18 | Accepted | 3ms | 3924 KiB | ||||
19 | Accepted | 3ms | 4008 KiB | ||||
20 | Accepted | 3ms | 4004 KiB | ||||
21 | Accepted | 3ms | 4236 KiB | ||||
22 | Accepted | 3ms | 4248 KiB | ||||
23 | Accepted | 3ms | 4148 KiB | ||||
24 | Accepted | 3ms | 4152 KiB | ||||
25 | Accepted | 3ms | 4148 KiB | ||||
26 | Accepted | 3ms | 4296 KiB | ||||
subtask4 | 0/40 | ||||||
27 | Wrong answer | 92ms | 7232 KiB | ||||
28 | Accepted | 97ms | 7232 KiB | ||||
29 | Accepted | 92ms | 7232 KiB | ||||
30 | Accepted | 92ms | 7228 KiB | ||||
31 | Accepted | 92ms | 7380 KiB | ||||
32 | Accepted | 93ms | 7236 KiB | ||||
33 | Accepted | 94ms | 7356 KiB | ||||
34 | Accepted | 93ms | 7336 KiB | ||||
35 | Accepted | 93ms | 7236 KiB | ||||
36 | Accepted | 82ms | 7364 KiB | ||||
37 | Accepted | 71ms | 7236 KiB | ||||
38 | Accepted | 43ms | 7232 KiB | ||||
39 | Accepted | 89ms | 7444 KiB | ||||
40 | Accepted | 90ms | 7440 KiB | ||||
41 | Accepted | 68ms | 7444 KiB | ||||
42 | Accepted | 90ms | 7720 KiB | ||||
43 | Accepted | 64ms | 7824 KiB |