114292024-09-15 14:26:40CsongiPontos Átlagcpp17Accepted 100/10045ms1404 KiB
#include <bits/stdc++.h>
using namespace std;

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

    long long int n, k, sum = 0;
    cin >> n >> k;
    vector<int> q(n);
    long long int sum2 = n*k;
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
        sum += q[i];
    }

    if (sum < sum2)
    {
        cout << 1 << endl;
        return 0;
    }
    sort(q.begin(), q.end());
    int ki = 0;
    while (sum > sum2)
    {
        sum -= q.back() - 1;
        q.pop_back(); ki++;
    }
    cout << ki << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms504 KiB
2Accepted2ms360 KiB
subtask220/20
3Accepted3ms360 KiB
4Accepted3ms536 KiB
5Accepted3ms360 KiB
6Accepted3ms456 KiB
7Accepted2ms360 KiB
8Accepted3ms384 KiB
9Accepted3ms360 KiB
10Accepted3ms384 KiB
11Accepted3ms360 KiB
12Accepted3ms500 KiB
13Accepted3ms360 KiB
subtask340/40
14Accepted3ms504 KiB
15Accepted3ms504 KiB
16Accepted3ms420 KiB
17Accepted3ms400 KiB
18Accepted3ms240 KiB
19Accepted3ms232 KiB
20Accepted3ms504 KiB
21Accepted3ms360 KiB
22Accepted2ms504 KiB
23Accepted3ms504 KiB
24Accepted3ms504 KiB
25Accepted3ms496 KiB
26Accepted3ms360 KiB
subtask440/40
27Accepted25ms1144 KiB
28Accepted45ms1180 KiB
29Accepted43ms1128 KiB
30Accepted43ms1300 KiB
31Accepted43ms1272 KiB
32Accepted45ms1128 KiB
33Accepted45ms1400 KiB
34Accepted45ms1272 KiB
35Accepted43ms1404 KiB
36Accepted28ms1272 KiB
37Accepted45ms1128 KiB
38Accepted20ms1272 KiB
39Accepted43ms1272 KiB
40Accepted43ms1272 KiB
41Accepted34ms1128 KiB
42Accepted43ms1272 KiB
43Accepted32ms1128 KiB