Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#pragma GCC optimize("Ofast,no-stack-protector")
- //#pragma GCC target("avx")
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <fstream>
- #include <functional>
- #include <cmath>
- #include <set>
- #include <deque>
- #include <queue>
- #include <utility>
- #include <map>
- #include <string>
- #include <iomanip>
- #include <utility>
- #include <ctype.h>
- #include <stdio.h>
- #include <random>
- #include <ctime>
- #include <unordered_map>
- #include <unordered_set>
- #include <exception>
- #include <stdexcept>
- #define se second
- #define fi first
- #define mp make_pair
- #define pb push_back
- typedef long long ll;
- using namespace std;
- int main() {
- iostream::sync_with_stdio(false);
- string s;
- cin >> s;
- string alph = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
- int ln = 0;
- vector<int> a;
- for (auto e : s) {
- if (find(alph.begin(), alph.end(), e) != alph.end()) ln++;
- else {
- if (ln) {
- a.pb(ln);
- ln = 0;
- }
- }
- }
- int n = (int)a.size();
- vector<pair<int, int>> dp(n);
- dp[0].fi = a[0];
- dp[0].se = 0;
- for (int i = 0; i + 1 < n; i++) {
- dp[i + 1].fi = dp[i].se + a[i + 1];
- dp[i + 1].se = max(dp[i].fi, dp[i].se);
- }
- cout << max(dp[n - 1].fi, dp[n - 1].se);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement