114632024-09-29 16:56:58bzyPontos Átlagcpp17Runtime error 60/10096ms1384 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k; cin >> n >> k;
    long long sum = 0;
    vector <int> P(n); 
    int 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
2Accepted3ms384 KiB
subtask220/20
3Accepted3ms360 KiB
4Accepted3ms536 KiB
5Accepted3ms384 KiB
6Accepted3ms488 KiB
7Accepted3ms256 KiB
8Accepted3ms296 KiB
9Accepted3ms384 KiB
10Accepted2ms376 KiB
11Accepted2ms360 KiB
12Accepted3ms504 KiB
13Accepted2ms360 KiB
subtask340/40
14Accepted3ms360 KiB
15Accepted3ms372 KiB
16Accepted3ms532 KiB
17Accepted3ms360 KiB
18Accepted3ms360 KiB
19Accepted3ms360 KiB
20Accepted3ms504 KiB
21Accepted3ms360 KiB
22Accepted3ms412 KiB
23Accepted3ms360 KiB
24Accepted3ms416 KiB
25Accepted3ms256 KiB
26Accepted3ms504 KiB
subtask40/40
27Runtime error93ms1284 KiB
28Runtime error93ms1220 KiB
29Partially correct93ms1260 KiB
30Runtime error93ms1272 KiB
31Runtime error92ms1256 KiB
32Runtime error93ms1256 KiB
33Partially correct96ms1128 KiB
34Runtime error93ms1384 KiB
35Runtime error93ms1256 KiB
36Accepted82ms1128 KiB
37Wrong answer93ms1132 KiB
38Accepted41ms1128 KiB
39Runtime error90ms1180 KiB
40Runtime error90ms1128 KiB
41Runtime error68ms1256 KiB
42Runtime error93ms1312 KiB
43Accepted61ms1128 KiB