Thông tin
cin >> n; m=1; for (int i=1;i<=n;i++) { cin >> h[i]; a[i]=t.size(); while (t.empty()==0) { if (h[i]>t.top()) t.pop(); else break; } t.push(h[i]); } while (t.empty()==0) t.pop(); for (int i=n;i>0;i--) { b[i]=t.size(); while (t.empty()==0) { if (h[i]>t.top()) t.pop(); else break; } t.push(h[i]); } cin >> k; for (int i=1;i<=n;i++) { if (k[i-1]=='L') cout << a[i] << ' '; else cout << b[i] << ' '; }