86842024-01-25 10:52:34qertendVirágos rét (50 pont)cpp17Accepted 50/5020ms4076 KiB
#include <iostream>
using namespace std;

/**
 * Fails on njduge tests 15, 18, 22
*/
int main()
{
    long long retekSzama, K;
    cin >> retekSzama;
    cin >> K;

    long long szabadRetek = 0;
    bool ret;
    for (int i = 0; i < retekSzama; i++) {
        cin >> ret;
        szabadRetek += ret;
    }
    long long N = szabadRetek-K+1;
    if (szabadRetek >= K) cout << (int) N*(N+1)/2;
    else cout << 0;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1872 KiB
2Accepted0/03ms2124 KiB
3Accepted0/020ms2332 KiB
4Accepted2/23ms2440 KiB
5Accepted2/23ms2500 KiB
6Accepted2/23ms2632 KiB
7Accepted3/33ms2712 KiB
8Accepted3/33ms3112 KiB
9Accepted3/33ms3340 KiB
10Accepted2/23ms3328 KiB
11Accepted3/33ms3540 KiB
12Accepted2/23ms3472 KiB
13Accepted3/33ms3664 KiB
14Accepted2/218ms3732 KiB
15Accepted2/218ms3736 KiB
16Accepted3/319ms3852 KiB
17Accepted3/319ms3988 KiB
18Accepted3/320ms4076 KiB
19Accepted3/319ms3952 KiB
20Accepted3/319ms3956 KiB
21Accepted3/320ms3952 KiB
22Accepted3/319ms3956 KiB