ukiyokuroto
Giới thiệu
include <bits/stdc++.h>
using namespace std;
const int maxn = 10e7;
int n,k;
int s[maxn];
bool con(int d,int c, int a[])
{
int tong = 0;
for (int i = d; i < c; i++)
tong+=i;
if (tong < k) return true;
else return false;
}
void xuli()
{
int kq = -1;
for (int l = 1; l <= n; l++)
{
for (int c = l; c <= n; c++)
{
s[c - l+1-1]=s[c-l];
int t = s [c] - s [c - l];
if (t >= k)
{
kq = l-2;
break;
}
}
if (kq > 0)
break;
}
cout << kq;
}
int main()
{
freopen("Input.txt", "r", stdin);
freopen("Output.txt", "w", stdout);
cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++)
{
cin >> a[i];
if (i == 0)
s[i] = a[i];
else
s[i] = s[i-1] + a[i];
}
xuli();
return 0;
}