initial commit
This commit is contained in:
commit
7aacde99f4
12 changed files with 296 additions and 0 deletions
45
codeforces/991/a.cc
Normal file
45
codeforces/991/a.cc
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
#define FOR(x) for (size_t i = 0; i < (x).size(); ++i)
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cerr << #x << " = " << (x) << '\n'
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
void solve() {
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
size_t length = 0, words = 0;
|
||||
bool order = true;
|
||||
string s;
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
cin >> s;
|
||||
if (length + s.size() <= m && order) {
|
||||
dbg(m);
|
||||
length += s.size();
|
||||
++words;
|
||||
} else {
|
||||
order = false;
|
||||
}
|
||||
}
|
||||
cout << words << '\n';
|
||||
}
|
||||
|
||||
int main() {
|
||||
ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue