- // de 12 (2018-2019) DONG THAP
- #include<bits/stdc++.h>
- using namespace std ;
- int n,a[1000000];
- long long k,res=0,ngay = 0,MIN = 51000 ;
- int main()
- {
- cin >> n >> k;
- for (int i=1 ; i<=n ; i++)
- cin >> a[i];
- for(int i=1 ; i<=n ; i++)
- {
- int x = i;
- while(res <= k)
- {
- res = res + a[x];
- x++;
- ngay++;
- }
- if ((ngay < MIN) and (ngay!=0) and (ngay!=1))
- {
- MIN = ngay;
- }
- ngay = 0;
- res = 0 ;
- }
- if(MIN!=51000)
- cout << MIN ;
- else cout << -1;
- return 0;
- }
Raw Paste