Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <iostream>
- #include <string>
- using namespace std;
- string s;
- int main() {
- int h, w, n, now_pos = 0, now_string = 1;
- cin >> h >> w >> n;
- for (int i = 0; i < n; i++) {
- cin >> s;
- int l = s.size();
- if (now_pos + l > w) {
- now_pos = l + 1;
- now_string++;
- }
- else
- now_pos += l + 1;
- }
- cout << (now_string / h) + int(now_string % h != 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement