114642024-09-29 16:59:49bzyPontos Átlagcpp17Accepted 100/10093ms1272 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  n, k; cin >> n >> k;
    long long sum = 0;
    vector <int> P(n); 
    long long sum2 = n*k;
    for(int i = 0; i < n; i++){
        cin >> P[i];
        sum += P[i];
    }
    if(sum2 == sum) cout << 0 << "\n";
    else if(sum2 > sum) cout << 1 << "\n";
    else{
        sort(P.begin(),P.end(),greater<>());
        int ans = 0;
        int current = 0;
        while(sum > sum2){
            sum -= P[current] - 1;
            current++;
            ans++;
        }
        cout << ans << "\n";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms360 KiB
2Accepted2ms504 KiB
subtask220/20
3Accepted3ms384 KiB
4Accepted3ms384 KiB
5Accepted2ms360 KiB
6Accepted3ms384 KiB
7Accepted2ms364 KiB
8Accepted3ms232 KiB
9Accepted3ms360 KiB
10Accepted2ms360 KiB
11Accepted2ms384 KiB
12Accepted2ms376 KiB
13Accepted2ms232 KiB
subtask340/40
14Accepted4ms360 KiB
15Accepted3ms376 KiB
16Accepted3ms488 KiB
17Accepted4ms384 KiB
18Accepted3ms360 KiB
19Accepted3ms360 KiB
20Accepted3ms496 KiB
21Accepted3ms368 KiB
22Accepted3ms360 KiB
23Accepted3ms360 KiB
24Accepted3ms632 KiB
25Accepted3ms384 KiB
26Accepted3ms360 KiB
subtask440/40
27Accepted74ms1128 KiB
28Accepted93ms1144 KiB
29Accepted93ms1268 KiB
30Accepted93ms1144 KiB
31Accepted93ms1128 KiB
32Accepted93ms1128 KiB
33Accepted93ms1128 KiB
34Accepted93ms1272 KiB
35Accepted93ms1128 KiB
36Accepted83ms1180 KiB
37Accepted74ms1128 KiB
38Accepted43ms1128 KiB
39Accepted90ms1168 KiB
40Accepted92ms1256 KiB
41Accepted68ms1128 KiB
42Accepted92ms1128 KiB
43Accepted63ms1128 KiB