Skip to content

Commit 0597ee9

Browse files
committed
solved 22862
1 parent 1b751da commit 0597ee9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

22000/22862/22862.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
#define FOR(i, a, b) for (int i = a; i < b; i++)
5+
6+
int arr[1000000];
7+
8+
int main() {
9+
ios::sync_with_stdio(false); cin.tie(NULL);
10+
11+
int N, K, t, s=0, e=0, odds=0, ans=0;
12+
13+
cin>>N>>K;
14+
FOR(i, 0, N)
15+
cin>>arr[i];
16+
17+
while(e < N){
18+
if(arr[e]%2){
19+
if(odds >= K){
20+
if(arr[s]%2)
21+
--odds;
22+
s++;
23+
}else{
24+
odds++;
25+
e++;
26+
}
27+
}else
28+
e++;
29+
ans = max(ans, e-s-odds);
30+
}
31+
cout<<ans;
32+
33+
return 0;
34+
}

0 commit comments

Comments
 (0)