65352023-12-07 22:00:59TuruTamasPontos Átlagcpp17Wrong answer 0/10097ms7996 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
1Accepted3ms1884 KiB
2Accepted3ms2076 KiB
subtask20/20
3Accepted3ms2552 KiB
4Wrong answer2ms2596 KiB
5Accepted2ms2504 KiB
6Accepted3ms2712 KiB
7Accepted3ms2916 KiB
8Accepted2ms2916 KiB
9Accepted3ms3048 KiB
10Accepted3ms3272 KiB
11Accepted3ms3652 KiB
12Accepted3ms3620 KiB
13Accepted3ms3672 KiB
subtask30/40
14Wrong answer3ms3664 KiB
15Accepted3ms3724 KiB
16Accepted3ms3948 KiB
17Accepted3ms3932 KiB
18Accepted3ms4064 KiB
19Accepted3ms4276 KiB
20Accepted3ms4360 KiB
21Accepted3ms4388 KiB
22Accepted3ms4480 KiB
23Accepted3ms4404 KiB
24Accepted3ms4588 KiB
25Accepted3ms4676 KiB
26Accepted3ms4672 KiB
subtask40/40
27Wrong answer93ms7760 KiB
28Accepted93ms7760 KiB
29Accepted97ms7996 KiB
30Accepted93ms7864 KiB
31Accepted93ms7848 KiB
32Accepted93ms7756 KiB
33Accepted93ms7756 KiB
34Accepted94ms7760 KiB
35Accepted93ms7760 KiB
36Accepted83ms7760 KiB
37Accepted75ms7888 KiB
38Accepted45ms7760 KiB
39Accepted90ms7760 KiB
40Accepted93ms7756 KiB
41Accepted68ms7756 KiB
42Accepted92ms7844 KiB
43Accepted64ms7852 KiB