82342024-01-13 18:41:57rennVirágos rét (50 pont)cpp17Accepted 50/509ms3772 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {

    cin.tie(0);
    ios::sync_with_stdio(0);

    long long n, k;
    long long s;
    cin >> n >> k;
    long long retek = 0, utvonalak = 0;

    while(n--)
    {
        cin >> s;
        retek += s;
    }
    //cout << retek << endl;
    
    if(retek < k)
    {
        cout << "0\n";
        exit(0);
    }

    for(long long i = 1; i <= retek-k+1; i++)
    {
        //cout << "asd: " << retek-i-k+2 << endl;
        utvonalak += retek-i-k+2;
    }
    cout << utvonalak << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms2076 KiB
2Accepted0/03ms2172 KiB
3Accepted0/09ms2180 KiB
4Accepted2/23ms2300 KiB
5Accepted2/23ms2512 KiB
6Accepted2/23ms2728 KiB
7Accepted3/33ms2896 KiB
8Accepted3/32ms2980 KiB
9Accepted3/33ms3132 KiB
10Accepted2/22ms2984 KiB
11Accepted3/33ms2984 KiB
12Accepted2/23ms2988 KiB
13Accepted3/33ms2984 KiB
14Accepted2/28ms3120 KiB
15Accepted2/28ms3200 KiB
16Accepted3/39ms3200 KiB
17Accepted3/39ms3308 KiB
18Accepted3/39ms3348 KiB
19Accepted3/39ms3544 KiB
20Accepted3/39ms3640 KiB
21Accepted3/39ms3752 KiB
22Accepted3/38ms3772 KiB