116242024-11-01 12:02:38MagyarKendeSZLGPontos Átlagcpp17Accepted 100/10043ms2040 KiB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);

    ll N, K;
    cin >> N >> K;

    vector<ll> p(N);
    for (ll& x : p) cin >> x;
    sort(p.rbegin(), p.rend());

    ll avg = accumulate(p.begin(), p.end(), 0LL),
       goal = K * N;

    if (avg == goal) {
        cout << "0\n";
        exit(0);
    }

    if (avg < goal) {
        cout << "1\n";
        exit(0);
    }

    for (int i = 0; i < N; i++) {
        avg -= p[i] - 1;
        if (avg <= goal) {
            cout << i + 1 << "\n";
            exit(0);
        }
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms320 KiB
2Accepted1ms320 KiB
subtask220/20
3Accepted1ms320 KiB
4Accepted1ms320 KiB
5Accepted1ms320 KiB
6Accepted1ms508 KiB
7Accepted1ms320 KiB
8Accepted1ms320 KiB
9Accepted1ms508 KiB
10Accepted1ms320 KiB
11Accepted1ms320 KiB
12Accepted1ms320 KiB
13Accepted1ms320 KiB
subtask340/40
14Accepted1ms508 KiB
15Accepted1ms320 KiB
16Accepted1ms320 KiB
17Accepted1ms320 KiB
18Accepted1ms392 KiB
19Accepted1ms500 KiB
20Accepted1ms512 KiB
21Accepted1ms320 KiB
22Accepted1ms324 KiB
23Accepted1ms320 KiB
24Accepted1ms500 KiB
25Accepted1ms320 KiB
26Accepted1ms320 KiB
subtask440/40
27Accepted43ms2004 KiB
28Accepted43ms1848 KiB
29Accepted43ms2012 KiB
30Accepted43ms2012 KiB
31Accepted43ms2028 KiB
32Accepted43ms1848 KiB
33Accepted43ms2028 KiB
34Accepted43ms2040 KiB
35Accepted43ms2040 KiB
36Accepted29ms1848 KiB
37Accepted43ms1848 KiB
38Accepted21ms2000 KiB
39Accepted43ms2004 KiB
40Accepted41ms2028 KiB
41Accepted32ms2004 KiB
42Accepted41ms2004 KiB
43Accepted32ms2040 KiB