Advertisement
anon20016

I

Nov 18th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #define _CRT_SECURE_NO_DEPRECATE
  2.  
  3. #include <iostream>
  4. #include <vector>
  5. #include <string>
  6. #include <map>
  7. #include <set>
  8. #include <algorithm>
  9.  
  10. #define ull unsigned long long
  11. #define ll long long
  12.  
  13. using namespace std;
  14.  
  15. const int N = 1001;
  16. const ll INF = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000ll;
  17.  
  18. //ll a[N];
  19. ll d[N];
  20.  
  21.  
  22. int main() {
  23. //freopen("input.txt", "r", stdin);
  24. //freopen("output.txt", "w", stdout);
  25. int n;
  26. cin >> n;
  27. string s;
  28. cin >> s;
  29. d[0] = 0;
  30. for (int i = 1; i < n; i++) {
  31. d[i] = -1;
  32. if (i - 3 >= 0 && s[i - 3] != 'w') {
  33. d[i] = max(d[i], d[i - 3]);
  34. }
  35. if (i - 1 >= 0 && s[i - 1] != 'w') {
  36. d[i] = max(d[i], d[i - 1]);
  37. }
  38. if (i - 5 >= 0 && s[i - 5] != 'w') {
  39. d[i] = max(d[i], d[i - 5]);
  40. }
  41. if (d[i] != -1) {
  42. if (s[i] == '"') {
  43. d[i]++;
  44. }
  45. }
  46. }
  47. cout << d[n - 1];
  48.  
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement