144942025-01-12 19:39:10sarminÚthasználati díj (75 pont)cpp17Accepted 75/758ms648 KiB
// Created by Armin on 1/12/2025.
// See https://njudge.hu/problemset/main/NT24_Belepo/

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<int, int>;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n, k; cin >> n >> k;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      int x; cin >> x;
      if (x == 1) v.push_back(x);
    }

    int result = 0, s = (int) v.size();
    for (int i = 0; i < s; i++) {
      result += min(s - (i + 1), k - 1);
    }
    cout << result << '\n';
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted0/08ms564 KiB
4Accepted5/51ms316 KiB
5Accepted5/51ms540 KiB
6Accepted5/51ms316 KiB
7Accepted5/51ms348 KiB
8Accepted5/51ms500 KiB
9Accepted5/51ms316 KiB
10Accepted5/51ms316 KiB
11Accepted5/51ms316 KiB
12Accepted5/51ms316 KiB
13Accepted5/51ms548 KiB
14Accepted5/58ms436 KiB
15Accepted5/58ms564 KiB
16Accepted5/58ms552 KiB
17Accepted5/58ms648 KiB
18Accepted5/58ms548 KiB