当前位置: 首页> 文旅> 美景 > 深圳画册公司_十大顶级咨询公司_营销活动推广方案_产品推广营销

深圳画册公司_十大顶级咨询公司_营销活动推广方案_产品推广营销

时间:2025/8/26 14:48:56来源:https://blog.csdn.net/jj12345jj198999/article/details/145099132 浏览次数:0次
深圳画册公司_十大顶级咨询公司_营销活动推广方案_产品推广营销

time limit per test

1 second

memory limit per test

256 megabytes

Kostya has a text ss consisting of nn words made up of Latin alphabet letters. He also has two strips on which he must write the text. The first strip can hold mm characters, while the second can hold as many as needed.

Kostya must choose a number xx and write the first xx words from ss on the first strip, while all the remaining words are written on the second strip. To save space, the words are written without gaps, but each word must be entirely on one strip.

Since space on the second strip is very valuable, Kostya asks you to choose the maximum possible number xx such that all words s1,s2,…,sxs1,s2,…,sx fit on the first strip of length mm.

Input

The first line contains an integer tt (1≤t≤10001≤t≤1000) — the number of test cases.

The first line of each test case contains two integers nn and mm (1≤n≤501≤n≤50; 1≤m≤5001≤m≤500) — the number of words in the list and the maximum number of characters that can be on the first strip.

The next nn lines contain one word sisi of lowercase Latin letters, where the length of sisi does not exceed 1010.

Output

For each test case, output the maximum number of words xx such that the first xx words have a total length of no more than mm.

Example

Input

Copy

 

5

3 1

a

b

c

2 9

alpha

beta

4 12

hello

world

and

codeforces

3 2

ab

c

d

3 2

abc

ab

a

Output

Copy

1
2
2
1
0

解题说明:此题是一道模拟题,为了让前x个字母写在第一页上,遍历即可。

#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int t;
int n, m;
string s[200005];int main()
{cin >> t;while (t--){cin >> n >> m;int cnt = 0;for (int i = 1; i <= n; i++){cin >> s[i];}for (int i = 1; i <= n; i++){if (m >= s[i].size()){m -= s[i].size();cnt++;}else{break;}}cout << cnt <<endl;}return 0;
}

关键字:深圳画册公司_十大顶级咨询公司_营销活动推广方案_产品推广营销

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: