65342023-12-07 22:00:44TuruTamasPontos Átlagpython3Runtime error 0/10018ms13452 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 unsigned long long ull;

ull N, K, ossz;
ull 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);
    }
    sort(P, P+N);
    ull r = 0;
    if (K > ossz) {
        for (ull i = 0; i < N; i++) {
            ossz += 1'000'000-P[i];
            r++;
            if (ossz >= K) {
                cout << r << endl;
                exit(0);
            }
        }
    }
    else {
        for (ull i = N-1; i >= 0; i--) {
            ossz -= P[i]-1;
            r++;
            if (ossz <= K) {
                cout << r << endl;
                exit(0);
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error18ms11004 KiB
2Runtime error17ms11564 KiB
subtask20/20
3Runtime error17ms11304 KiB
4Runtime error17ms11716 KiB
5Runtime error17ms11704 KiB
6Runtime error17ms11892 KiB
7Runtime error17ms12068 KiB
8Runtime error17ms12040 KiB
9Runtime error17ms12008 KiB
10Runtime error17ms12072 KiB
11Runtime error17ms12132 KiB
12Runtime error17ms12268 KiB
13Runtime error17ms12448 KiB
subtask30/40
14Runtime error17ms12428 KiB
15Runtime error17ms12340 KiB
16Runtime error17ms12364 KiB
17Runtime error17ms12780 KiB
18Runtime error17ms12828 KiB
19Runtime error17ms13028 KiB
20Runtime error17ms12780 KiB
21Runtime error17ms13064 KiB
22Runtime error17ms12880 KiB
23Runtime error17ms12672 KiB
24Runtime error17ms12824 KiB
25Runtime error17ms12952 KiB
26Runtime error17ms12896 KiB
subtask40/40
27Runtime error17ms12908 KiB
28Runtime error17ms13108 KiB
29Runtime error17ms12980 KiB
30Runtime error17ms13248 KiB
31Runtime error17ms12988 KiB
32Runtime error17ms13280 KiB
33Runtime error17ms13452 KiB
34Runtime error17ms13252 KiB
35Runtime error17ms13348 KiB
36Runtime error17ms13104 KiB
37Runtime error17ms13428 KiB
38Runtime error17ms13352 KiB
39Runtime error17ms13416 KiB
40Runtime error17ms13212 KiB
41Runtime error17ms13388 KiB
42Runtime error17ms13424 KiB
43Runtime error17ms13084 KiB