86162024-01-23 17:53:51Wrinkle1564Virágos rét (50 pont)cpp17Wrong answer 46/5020ms4300 KiB
#include <cstdint>
#include <iostream>

using std::cin;
using std::cout;

using u32 = uint32_t;
using u64 = uint64_t;

auto main() -> int {
    // retek szama, 1 <= `n` <= 100_000
    u32 n = 0;
    // ennyirol akar szedni: ennyi igaz kell, 1 <= `k` <= `n`
    u32 k = 0;
    cin >> n >> k;

    // retek szama, ahol szabad szedni
    u32 allowed = 0;
    // ideiglenes valtozo, ebbe olvasok
    bool tmp = false;
    for (u32 i = 0; i < n; i++) {
        // beolvasom
        cin >> tmp;
        // ha igaz, eltarolom
        if (tmp) {
            allowed++;
        }
    }

    // ennyi kell egymas utan
    u64 N = allowed - k + 1;
    cout << N * (N + 1) / 2;

    cout << std::endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base46/50
1Accepted0/03ms2020 KiB
2Accepted0/03ms2112 KiB
3Accepted0/020ms2476 KiB
4Accepted2/23ms2588 KiB
5Wrong answer0/23ms2736 KiB
6Wrong answer0/23ms2988 KiB
7Accepted3/33ms3120 KiB
8Accepted3/33ms3340 KiB
9Accepted3/33ms3436 KiB
10Accepted2/23ms3676 KiB
11Accepted3/33ms3732 KiB
12Accepted2/23ms3732 KiB
13Accepted3/33ms3976 KiB
14Accepted2/218ms4100 KiB
15Accepted2/218ms4188 KiB
16Accepted3/320ms4180 KiB
17Accepted3/319ms4152 KiB
18Accepted3/320ms4156 KiB
19Accepted3/319ms4156 KiB
20Accepted3/319ms4160 KiB
21Accepted3/320ms4300 KiB
22Accepted3/319ms4296 KiB