Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<cstdlib>
- #include<algorithm>
- #include<cmath>
- #include<cstring>
- using namespace std;
- const int MAXN = 10000;
- string a;
- int main() {
- int h, w, n, cnt = 0, cnt1 = 1, cnt2 = 1, pr = 0;
- cin >> h >> w >> n;
- for (int i = 0; i < n; i++) {
- cin >> a;
- if (pr != 0)
- cnt += a.length() + 1;
- else cnt = a.length();
- if (cnt > w) {
- cnt1++;
- cnt = a.length();
- pr = 0;
- }
- if (cnt1 > h) {
- cnt2++;
- cnt1 = 1;
- }
- pr++;
- }
- cout << cnt2;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment