为什么只有90

P3662 [USACO17FEB] Why Did the Cow Cross the Road II S

@[laotan](/space/show?uid=159375) 帮你改过了 ```cpp #include <iostream> #include <string.h> using namespace std; int s[100201]; int main (){ int n,k,b,ans=0,lans; cin >> n >> k >> b; memset(s,0,sizeof(s)); for(int i=0;i<b;i++){ int x; cin >> x; s[x]=1; } for(int i=1;i<=k;i++){ if(s[i]) ans++; } lans=ans; for(int i=2;i<=n-k+1;i++){ if(s[i-1]) lans--; if(s[i+k-1]) lans++; if(lans<ans) ans=lans; } cout << ans <<endl; return 0; } ```
by Smile_Cindy @ 2019-05-01 16:57:32


@[Alpha](/space/show?uid=87058) 谢谢
by ltdj @ 2019-05-23 12:20:59


|