fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define Samurai ios_base::sync_with_stdio(false), cout.tie(NULL), cin.tie(NULL);
  4.  
  5. int main(){ Samurai
  6. int _t = 1;
  7. cin >> _t;
  8. for (int i = 1; i <= _t; i++){
  9. int n,m ; cin >> n >> m;
  10. string s = "";
  11. int ans = 0;
  12. bool ok = true;
  13. for(int i=0; i<n; i++){
  14. string x; cin >> x;
  15. if(s.size()+x.size() <= m && ok){
  16. ans++;
  17. s += x;
  18. }
  19. else ok = false;
  20. }
  21. cout << ans << '\n';
  22. }
  23. return 0;
  24. }
  25.  
  26.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
0