Advertisement
Malinovsky239

УРКОП 2011: I

Oct 22nd, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. string s;
  8.  
  9. int main() {
  10.     int h, w, n, now_pos = 0, now_string = 1;
  11.     cin >> h >> w >> n;
  12.  
  13.     for (int i = 0; i < n; i++) {
  14.         cin >> s;
  15.         int l = s.size();
  16.         if (now_pos + l > w) {
  17.             now_pos = l + 1;
  18.             now_string++;
  19.         }
  20.         else
  21.             now_pos += l + 1;      
  22.     }
  23.  
  24.     cout << (now_string / h) + int(now_string % h != 0);
  25.    
  26.     return 0;
  27. }
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement