Advertisement
lmarioza

Untitled

Aug 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define F first
  3. #define S second
  4. #define mp make_pair
  5. #define pb push_back
  6. #define INF 0x3f3f3f3f
  7. #define LINF 0x3f3f3f3f3f3f3f3fLL
  8.  
  9. using namespace std;
  10. typedef long long ll;
  11. typedef vector<int> vi;
  12. typedef set<int> si;
  13. typedef pair<int,int> ii;
  14. typedef vector<ii> vii;
  15. typedef map<string,int> msi;
  16. typedef map<int,int> mi;
  17.  
  18. int main(){
  19.     int n,l,c;
  20.     while(!cin.eof()){
  21.         cin >>n>>l>>c;
  22.         unsigned long int chars = c;
  23.         unsigned long int lines = l;
  24.         unsigned long int pages = 1;
  25.         for(int i=0;i<n;i++){
  26.             string word;
  27.             cin>>word;
  28.             if(word.size() > chars){
  29.                 chars =c-word.size();
  30.                 lines--;
  31.                 if(lines ==0){
  32.                     lines =l;
  33.                     pages++;
  34.                 }
  35.             }else{
  36.                 chars-=word.size();
  37.             }
  38.             if(chars>0)chars--;
  39.         }
  40.         cout << pages<<'\n';
  41.     }
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement