Advertisement
Josif_tepe

Untitled

Mar 16th, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include<math.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin>>n;
  9.     string s;
  10.     string niza[n];
  11.     for(int i=0;i<n;i++)
  12.     {
  13.         cin>>niza[i];
  14.     }
  15.     long long l=0;
  16.     int d=0;
  17.     long long rez=0;
  18.     for(int i=0;i<n;i++)
  19.     {
  20.         if(niza[i]=="LL" )
  21.         {
  22.            l++;
  23.         }
  24.         if(niza[i]=="DD")
  25.         {
  26.             l--;
  27.         }
  28.         rez+=fabs(l);
  29.     }
  30.     cout<<rez;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement