65362023-12-07 22:06:30TuruTamasPontos Átlagcpp17Wrong answer 0/100100ms8508 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);
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms2036 KiB
2Accepted3ms2052 KiB
subtask20/20
3Accepted3ms2264 KiB
4Accepted3ms2476 KiB
5Accepted3ms2808 KiB
6Accepted3ms2920 KiB
7Accepted3ms2984 KiB
8Wrong answer3ms2988 KiB
9Accepted3ms3116 KiB
10Accepted3ms3328 KiB
11Wrong answer3ms3432 KiB
12Wrong answer3ms3532 KiB
13Accepted3ms3540 KiB
subtask30/40
14Wrong answer3ms3632 KiB
15Accepted3ms3756 KiB
16Accepted3ms3840 KiB
17Accepted3ms4068 KiB
18Accepted3ms4076 KiB
19Accepted3ms4076 KiB
20Accepted3ms4108 KiB
21Accepted3ms4184 KiB
22Accepted3ms4192 KiB
23Accepted3ms4188 KiB
24Accepted3ms4192 KiB
25Accepted3ms4312 KiB
26Accepted3ms4396 KiB
subtask40/40
27Wrong answer90ms7516 KiB
28Accepted93ms7604 KiB
29Accepted90ms7600 KiB
30Accepted90ms7808 KiB
31Accepted90ms8024 KiB
32Accepted90ms7912 KiB
33Accepted90ms7904 KiB
34Accepted100ms7816 KiB
35Accepted92ms7908 KiB
36Accepted82ms7912 KiB
37Accepted71ms8116 KiB
38Accepted43ms8124 KiB
39Accepted87ms8116 KiB
40Accepted90ms8208 KiB
41Accepted67ms8296 KiB
42Accepted90ms8420 KiB
43Accepted64ms8508 KiB