delete pics to save space
This commit is contained in:
29
2.1121.cpp
Normal file
29
2.1121.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include<cstdio>
|
||||
#include<algorithm>
|
||||
using namespace std;
|
||||
const int maxn=100005;
|
||||
int n,S,b[maxn],x;
|
||||
int main()
|
||||
{
|
||||
#ifdef local
|
||||
freopen("pro.in","r",stdin);
|
||||
#endif
|
||||
while(scanf("%d%d",&n,&S)==2)
|
||||
{
|
||||
b[0]=0;
|
||||
for(int i=1;i<=n;i++)
|
||||
{
|
||||
scanf("%d",&x);
|
||||
b[i]=b[i-1]+x;
|
||||
}
|
||||
int res=n+1,i=1;
|
||||
for(int j=1;j<=n;j++)
|
||||
{
|
||||
if(b[i-1]+S>b[j]) continue;
|
||||
while(b[i]+S<=b[j]) i++;
|
||||
res=min(res,j-i+1);
|
||||
}
|
||||
printf("%d\n",res==n+1?0:res);
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user