246802026-02-13 14:33:53MarcÚthasználati díj (75 pont)cpp17Wrong answer 5/7528ms1148 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,k;
    cin >> n >> k;
    vector<int>a(n+1);
    for(int i=1; i<=n; i++){
        cin >> a[i];
    }
    int kii=0;
    int l=1;
    int jelen=1;
    int ind=1;
    while(a[ind]==0){
        ind++;
    }
    l=ind;
    for(int r=ind+1; r<=n; r++ ){
        if(a[r]==1){
            jelen++;
            if(jelen>k){
                
                l++;
                while(a[l]==0){
                    l++;
                }
                jelen--;
                
                l++;
                while(a[l]==0){
                    l++;
                }
                jelen--;
            }
            kii++;
            if(jelen ==k && k!=2){
                l++;
                while(a[l]==0){
                    l++;
                }
                jelen--;
                kii++;
            }
            cout << l << " " <<r << " " << jelen << '\n';
            }  
    }
    cout << kii;
}
SubtaskSumTestVerdictTimeMemory
base5/75
1Wrong answer0/01ms316 KiB
2Accepted0/01ms508 KiB
3Wrong answer0/027ms1076 KiB
4Wrong answer0/51ms316 KiB
5Wrong answer0/51ms508 KiB
6Wrong answer0/51ms316 KiB
7Accepted5/51ms316 KiB
8Wrong answer0/51ms324 KiB
9Wrong answer0/51ms316 KiB
10Wrong answer0/51ms500 KiB
11Wrong answer0/51ms316 KiB
12Wrong answer0/51ms316 KiB
13Wrong answer0/51ms316 KiB
14Wrong answer0/528ms1060 KiB
15Wrong answer0/528ms1148 KiB
16Wrong answer0/528ms1004 KiB
17Wrong answer0/528ms1008 KiB
18Wrong answer0/527ms1076 KiB