Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: dixtosa1
- PROG: milk2
- LANG: C++11
- */
- #pragma comment(linker, "/STACK:16777216")
- #include <iostream>
- #include <fstream>
- #include <cstdio>
- #include <stdio.h>
- #include <cstdlib>
- #include <stdlib.h>
- #include <string>
- //#include <string.h>
- #include <list>
- #include <fstream>
- #include <algorithm>
- #include <cmath>
- #include <map>
- #include <vector>
- #include <iomanip>
- #include <queue>
- #include <deque>
- #include <set>
- #include <stack>
- #include <sstream>
- #include <assert.h>
- #include <functional> //std::greater<int>
- //#include <tuple>
- //#include "Biginteger.cpp"
- //#include "sqrt.cpp"
- //#include "tree.cpp"
- //#include "funcs.cpp"
- typedef long long ll;
- typedef std::pair<ll,ll> pii;
- #define ALL(x) (x).begin(), (x).end()
- #define forn(N) for(ll i = 0; i<(int)N; i++)
- #define fornj(N) for(ll j = 0; j<(int)N; j++)
- #define fornk(N) for(ll k = 0; k<(int)N; k++)
- #define foreach(c,itr) for(auto itr=(c).begin();itr!=(c).end();itr++)
- #define PI 3.1415926535897932384626433
- #define LINF (1LL<<60)
- #define INF (1<<30)
- //#define MOD 1000007
- #define awesome vector<int> A(N); forn(N) scanf("%d", &A[i]);
- #define v vector
- #define File "Patterns"
- using namespace std;
- v<int> DP(10000);
- int MAX = -INF, ans = 0;
- int main()
- {
- #if defined(_DEBUG) || defined(_RELEASE)
- freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
- #else
- //freopen(File".in", "r", stdin); freopen(File".out", "w", stdout);
- #endif
- v<int> A(1);
- char chr;
- while(scanf("%c", &chr) == 1)
- {
- if (isalpha(chr)) A.back()++;
- else if (A.back() > 0) A.push_back(0);
- }
- int N = A.size();
- if (N == 1) return cout << A[0], 0;
- DP[0] = A[0];
- DP[1] = A[1];
- MAX = DP[0];
- ans = max(DP[0], DP[1]);
- for(int i = 2; i<N; i++)
- {
- DP[i] = A[i] + MAX;
- MAX = max(MAX, DP[i - 1]);
- ans = max(ans, DP[i]);
- }
- cout << ans;
- //printf("\n\ntime-%.3lf", clock()*1e-3);
- return 0;
- }
Add Comment
Please, Sign In to add comment