Advertisement
Guest User

b.cpp

a guest
Jun 26th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define rep(i, n) for(int i = 0; i < (int)(n); ++i)
  5. #define pb push_back
  6. #define ALL(a) begin(a), end(a)
  7. #define mp make_pair
  8. #define F first
  9. #define S second
  10. #define SZ(a) ((int)(a.size()))
  11. typedef long long ll;
  12. typedef pair<int, int> PI;
  13.  
  14.  
  15. bool ok(int i, vector<string> a){
  16.   int app[] = {5,7,5,7,7};
  17.   int aidx = 0;
  18.   while(i < SZ(a) && aidx < 5)    {
  19.     if(app[aidx] < SZ(a[i]))
  20.       return false;
  21.     if(app[aidx] == SZ(a[i])){
  22.       ++aidx;
  23.     }else
  24.       app[aidx] -= SZ(a[i]);
  25.     ++i;
  26.   }
  27.  
  28.   return aidx == 5;
  29. }
  30.  
  31. int main(int argc, char *argv[])
  32. {
  33.   int n;
  34.   while(cin >> n && n){
  35.     vector<string> in(n);
  36.     rep(i, n) cin >> in[i];
  37.  
  38.     rep(i, n){
  39.       if(ok(i, in)){
  40.         cout << i + 1<< endl;
  41.         break;
  42.       }
  43.     }
  44.   }
  45.   return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement