Advertisement
Josif_tepe

Untitled

Oct 17th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. using namespace  std;
  3.  
  4. int main() {
  5.     int n;
  6.     cin >> n;
  7.     int kolku_patiki = 0;
  8.     long long vleckanja = 0;
  9.     for(int i = 0; i < n; i++) {
  10.         string s;
  11.         cin >> s;
  12.         if(s == "LL") {
  13.             kolku_patiki++;
  14.         }
  15.         if(s == "DD") {
  16.             kolku_patiki--;
  17.         }
  18.         vleckanja += abs(kolku_patiki);
  19.     }
  20.     cout << vleckanja << endl;
  21.     return 0;
  22. }
  23.  
  24.  
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement