67102023-12-17 18:20:00MagyarKendeSZLGPontos Átlagcpp17Wrong answer 0/10046ms5944 KiB
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, K, sum;
    cin >> N >> K;
    
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        sum += P[i];
    }
    
    const int prod = N * K;
    
    if (prod == sum) {
        cout << 0 << endl;
    } else if (prod > sum || N == 1) {
        cout << 1 << endl;
    } else if (N == 2) {
        if (K > max(P[0], P[1]) + 1e6 || K < min(P[0], P[1]) + 1) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    } else {
        sort(P.begin(), P.end());
        for (int i = N - 1, result = 0; i >= 0; i--) {
            sum -= P[i] - 1;
            result++;
            if (prod >= sum) {
                cout << result << endl;
                return 0;
            }
        }
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Accepted3ms2164 KiB
subtask20/20
3Accepted3ms2400 KiB
4Accepted3ms2396 KiB
5Wrong answer3ms2392 KiB
6Accepted3ms2392 KiB
7Accepted3ms2612 KiB
8Accepted3ms2732 KiB
9Wrong answer3ms2940 KiB
10Wrong answer3ms3152 KiB
11Accepted3ms3364 KiB
12Accepted3ms3580 KiB
13Wrong answer3ms3948 KiB
subtask30/40
14Accepted3ms4056 KiB
15Accepted3ms4040 KiB
16Accepted3ms4268 KiB
17Accepted3ms4132 KiB
18Accepted3ms4128 KiB
19Accepted3ms4104 KiB
20Wrong answer3ms4104 KiB
21Wrong answer3ms4004 KiB
22Accepted3ms4012 KiB
23Accepted3ms4016 KiB
24Wrong answer3ms4012 KiB
25Accepted3ms4020 KiB
26Wrong answer3ms4088 KiB
subtask40/40
27Wrong answer45ms5516 KiB
28Partially correct46ms5424 KiB
29Wrong answer25ms5652 KiB
30Partially correct45ms5428 KiB
31Partially correct45ms5492 KiB
32Partially correct45ms5428 KiB
33Wrong answer26ms5560 KiB
34Partially correct46ms5692 KiB
35Partially correct45ms5684 KiB
36Wrong answer27ms5832 KiB
37Wrong answer45ms5776 KiB
38Accepted24ms5900 KiB
39Accepted43ms5704 KiB
40Wrong answer43ms5684 KiB
41Accepted35ms5944 KiB
42Wrong answer43ms5900 KiB
43Wrong answer34ms5900 KiB