We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7ab086 commit 782ed5fCopy full SHA for 782ed5f
2000D.cpp
@@ -19,6 +19,21 @@ void MASTER(){
19
ll n;cin>>n;
20
vector<ll>a(n);for(auto & in : a)cin>>in;
21
string s;cin>>s;
22
+
23
+ int l = 0;
24
+ int r = n-1;
25
26
+ ll sum = 0;
27
+ vector<int> pref(n + 1, 0);
28
+ for (int i = 0; i < n; i++)
29
+ pref[i + 1] = pref[i] + a[i];
30
31
32
+ while(l<r){
33
+ if(s[l] == 'L' && s[r] == 'R'){
34
+ sum += pref[r] - pref[l];
35
+ }
36
37
38
39
0 commit comments