6538 | 2023-12-07 22:27:20 | TuruTamas | Pontos Átlag | cpp17 | Accepted 100/100 | 93ms | 8080 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 (K > ossz) {
cout << 1 << endl;
exit(0);
}
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 | 2032 KiB | ||||
2 | Accepted | 3ms | 2260 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 3ms | 2480 KiB | ||||
4 | Accepted | 3ms | 2484 KiB | ||||
5 | Accepted | 3ms | 2784 KiB | ||||
6 | Accepted | 3ms | 2756 KiB | ||||
7 | Accepted | 3ms | 2860 KiB | ||||
8 | Accepted | 3ms | 3000 KiB | ||||
9 | Accepted | 3ms | 3208 KiB | ||||
10 | Accepted | 3ms | 3440 KiB | ||||
11 | Accepted | 3ms | 3588 KiB | ||||
12 | Accepted | 3ms | 3584 KiB | ||||
13 | Accepted | 3ms | 3580 KiB | ||||
subtask3 | 40/40 | ||||||
14 | Accepted | 3ms | 3660 KiB | ||||
15 | Accepted | 3ms | 3728 KiB | ||||
16 | Accepted | 4ms | 3920 KiB | ||||
17 | Accepted | 3ms | 3992 KiB | ||||
18 | Accepted | 3ms | 4100 KiB | ||||
19 | Accepted | 3ms | 3964 KiB | ||||
20 | Accepted | 3ms | 4108 KiB | ||||
21 | Accepted | 3ms | 4236 KiB | ||||
22 | Accepted | 3ms | 4204 KiB | ||||
23 | Accepted | 3ms | 4204 KiB | ||||
24 | Accepted | 3ms | 4252 KiB | ||||
25 | Accepted | 3ms | 4224 KiB | ||||
26 | Accepted | 3ms | 4316 KiB | ||||
subtask4 | 40/40 | ||||||
27 | Accepted | 71ms | 7560 KiB | ||||
28 | Accepted | 93ms | 7696 KiB | ||||
29 | Accepted | 93ms | 7696 KiB | ||||
30 | Accepted | 93ms | 7676 KiB | ||||
31 | Accepted | 93ms | 7676 KiB | ||||
32 | Accepted | 93ms | 7676 KiB | ||||
33 | Accepted | 93ms | 7680 KiB | ||||
34 | Accepted | 93ms | 7764 KiB | ||||
35 | Accepted | 93ms | 7724 KiB | ||||
36 | Accepted | 85ms | 7888 KiB | ||||
37 | Accepted | 71ms | 8020 KiB | ||||
38 | Accepted | 46ms | 8080 KiB | ||||
39 | Accepted | 90ms | 7928 KiB | ||||
40 | Accepted | 93ms | 7936 KiB | ||||
41 | Accepted | 71ms | 7932 KiB | ||||
42 | Accepted | 92ms | 7932 KiB | ||||
43 | Accepted | 64ms | 7932 KiB |