标签:
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<cstdlib> #include<algorithm> using namespace std; int n,S,sum,a[1010]; int main() { int t=0,s=0,res; scanf("%d%d",&n,&S); res=n+1; for(int i=0;i<n;i++) scanf("%d",&a[i]); for(;;) { while(t<n&&sum<S) { sum+=a[t++]; } if(sum<S) break; res=min(res,t-s); sum-=a[s++]; } if(res>n) res=0; printf("%d\n",res); return 0; }
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4286895.html