Skip to content

Commit 782ed5f

Browse files
committed
Auto-sync: 2026-02-25 15:19:57
1 parent b7ab086 commit 782ed5f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

2000D.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ void MASTER(){
1919
ll n;cin>>n;
2020
vector<ll>a(n);for(auto & in : a)cin>>in;
2121
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+
}
2237

2338

2439

0 commit comments

Comments
 (0)