Untitled
unknown
c_cpp
4 years ago
528 B
6
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...