Untitled
unknown
c_cpp
5 years ago
528 B
10
Indexable
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn = 100005;
int main()
{
int n;
cin >> n;
int brojac = 0;
long long rez = 0;
for(int i = 0; i < n; i++) {
string s;
cin >> s;
if(s == "LL") {
brojac += 1;
}
if(s == "DD") {
brojac -= 1;
}
rez += abs(brojac);
}
cout << rez << endl;
return 0;
}
/*
DD -1 brojac + 1
DD -2 brojac + 1
LL -1 brojac + 1
LL 0 brojac + 0
*/
Editor is loading...