Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define rep(i, n) for(int i = 0; i < (int)(n); ++i)
- #define pb push_back
- #define ALL(a) begin(a), end(a)
- #define mp make_pair
- #define F first
- #define S second
- #define SZ(a) ((int)(a.size()))
- typedef long long ll;
- typedef pair<int, int> PI;
- bool ok(int i, vector<string> a){
- int app[] = {5,7,5,7,7};
- int aidx = 0;
- while(i < SZ(a) && aidx < 5) {
- if(app[aidx] < SZ(a[i]))
- return false;
- if(app[aidx] == SZ(a[i])){
- ++aidx;
- }else
- app[aidx] -= SZ(a[i]);
- ++i;
- }
- return aidx == 5;
- }
- int main(int argc, char *argv[])
- {
- int n;
- while(cin >> n && n){
- vector<string> in(n);
- rep(i, n) cin >> in[i];
- rep(i, n){
- if(ok(i, in)){
- cout << i + 1<< endl;
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement