Advertisement
Guest User

Untitled

a guest
May 11th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.34 KB | None | 0 0
  1. //#pragma GCC optimize("Ofast,no-stack-protector")
  2. //#pragma GCC target("avx")
  3. #include <iostream>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <fstream>
  7. #include <functional>
  8. #include <cmath>
  9. #include <set>
  10. #include <deque>
  11. #include <queue>
  12. #include <utility>
  13. #include <map>
  14. #include <string>
  15. #include <iomanip>
  16. #include <utility>
  17. #include <ctype.h>
  18. #include <stdio.h>
  19. #include <random>
  20. #include <ctime>
  21. #include <unordered_map>
  22. #include <unordered_set>
  23. #include <exception>
  24. #include <stdexcept>
  25.  
  26. #define se second
  27. #define fi first
  28. #define mp make_pair
  29. #define pb push_back
  30.  
  31. typedef long long ll;
  32.  
  33. using namespace std;
  34.  
  35. int main() {
  36.     iostream::sync_with_stdio(false);
  37.     string s;
  38.     cin >> s;
  39.     string alph = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";
  40.     int ln = 0;
  41.     vector<int> a;
  42.     for (auto e : s) {
  43.         if (find(alph.begin(), alph.end(), e) != alph.end()) ln++;
  44.         else {
  45.             if (ln) {
  46.                 a.pb(ln);
  47.                 ln = 0;
  48.             }
  49.         }
  50.     }
  51.     int n = (int)a.size();
  52.     vector<pair<int, int>> dp(n);
  53.     dp[0].fi = a[0];
  54.     dp[0].se = 0;
  55.     for (int i = 0; i + 1 < n; i++) {
  56.         dp[i + 1].fi = dp[i].se + a[i + 1];
  57.         dp[i + 1].se = max(dp[i].fi, dp[i].se);
  58.     }
  59.     cout << max(dp[n - 1].fi, dp[n - 1].se);
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement