#include<bits/stdc++.h> using namespace std; int main() { int n,m,k,o=0,t=0,tot=0; cin>>n>>m; for(int i=0;i<n;i++) { cin>>k; if(k==1)o++; else t++; if(o!=0&&t!=0&&abs(o-t)>m) { tot++; o=0; t=0; } } cout<<tot; }
为什么我样例没过还过了一个点