#include using namespace std; int main(){ int N,M,pos=0,length,R=1,L=1; cin >> N >> M; int a[N]; length=N; char opr; for(int i=0; i> a[i]; } cin >> opr; if(opr=='R'){ pos=1; R++; }else{ pos=0; L++; } length--; for(int i=1; i> opr; if(opr=='R'){ if(pos==N-length){ if(length>1){ length--; R++; pos++; } }else{ pos++; } }else{ if(pos==0){ if(length>1){ length--; L++; } }else{ pos--; } } } for(int i=0; iN-R; i--){ a[N-R]+=a[i]; a[i]=0; } for(int i=0; i