ThaiPeen

timus 1881

May 16th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<cstdlib>
  4. #include<algorithm>
  5. #include<cmath>
  6. #include<cstring>
  7. using namespace std;
  8. const int MAXN = 10000;
  9. string a;
  10. int main() {
  11.     int h, w, n, cnt = 0, cnt1 = 1, cnt2 = 1, pr = 0;
  12.     cin >> h >> w >> n;
  13.     for (int i = 0; i < n; i++) {
  14.         cin >> a;
  15.         if (pr != 0)
  16.         cnt += a.length() + 1;
  17.         else cnt = a.length();
  18.         if (cnt > w) {
  19.             cnt1++;
  20.             cnt = a.length();
  21.             pr = 0;
  22.         }
  23.         if (cnt1 > h) {
  24.             cnt2++;
  25.             cnt1 = 1;
  26.         }
  27.         pr++;
  28.     }
  29.     cout << cnt2;
  30.     system("pause");
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment