solution
#include <iostream>
#include <vector>
using namespace std;
const int N = 100010;
int n, k;
int s[N];
vector<int> anss;
void solve(int i, int &j, int &tempsum)
{
int left = i, right = n;
while (left < right)
{
int mid = (left + right) / 2;
if (s[mid] - s[i - 1] >= k)
right = mid;
else
left = mid + 1;
}
j = right;
tempsum = s[j] - s[i - 1];
}
int main()
{
cin >> n >> k;
for (int i = 1; i <= n; i++)
{
cin>>s[i];
s[i] += s[i - 1];
}
int minans = s[n];
for (int i = 1; i <= n; i++)
{
int j, tempsum;
solve(i, j, tempsum);
if (tempsum > minans)
continue;
if (tempsum >= k)
{
if (tempsum < minans)
{
minans=tempsum;
anss.clear();
}
anss.push_back(i);
anss.push_back(j);
}
}
for (int i = 0; i <anss.size(); i += 2)
printf("%d-%d\n", anss[i], anss[i + 1]);
}