Vladislav_Bezruk

Some task

Dec 18th, 2020 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. string a;
  7. int count , maxCount = 0, minCount = 0;
  8.  
  9. int main() {
  10.  
  11.   getline(cin, a);
  12.   for (int i = 0 ; i < a.length() ; i++) {
  13.     if (a[i] == 'R') count++;
  14.     if (a[i] == 'L') count--;
  15.     if (count > maxCount) maxCount = count;
  16.     if (count < minCount) minCount = count;
  17.   }
  18.  
  19.   cout << maxCount - minCount + 1;
  20.  
  21.   return 0;
  22. }
Add Comment
Please, Sign In to add comment