Logo
(追記) (追記ここまで)

19744번 - Counting in the order 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB85363254.237%

문제

During the whole year Vasya didn't go to the university, therefore he didn't pass his exams and was expelled. That's how he ended up in the army. And the most popular exercise in the army is standing in the order.

There're $n$ soldiers in Vasya's troop including himself. Soldiers are standing in a row, each of them is looking to the left or to the right and have his own serial number from 1ドル$ to $n$ equal to his place in the order. The height of the $i$-th soldier is $h_i$. Vasya thinks that the soldier with number $i$ see the soldier with number $j$ if the following conditions are true:

  • soldier $i$ looks toward the soldier $j$;
  • all soldiers standing between them are not taller than soldier $j$.

For example, if there're 4ドル$ soldiers in the row with heights $h_1 = 178,ドル $h_2 = 180,ドル $h_3 = 170,ドル $h_4 = 190$ and all soldiers are looking to the left, then 2ドル$-nd soldier will see only the 1ドル$-st one, 3ドル$-rd --- only 2ドル$-nd one (because between him and first soldier there is higher second soldier), 4ドル$-th will see 2ドル$-nd and 3ドル$-rd soldier.

Because there is nothing to do in the order, Vasya wants to calculate how many soldiers see each of the soldiers.

입력

The first line of input contains number $n$ --- the number of soldiers in the row (1ドル \le n \le 10^5$).

The second line contains $n$ numbers $h_1, h_2, \ldots, h_n$ --- heights of soldiers in the row (1ドル \le h_i \le 10^9$).

The third line contains $n$ symbols representing the directions in which the soldiers look: $i$-th symbol is equal <<L>> if $i$-th soldier looks to the left, i.e. potentially can see only the soldiers with serial numbers 1,ドル 2, \ldots, i - 1,ドル or <<R>> if $i$-th soldier looks to the right and potentially can see only the soldier with serial numbers $i + 1, i + 2, \ldots, n$.

출력

Output $n$ integers, where $i$-th integer is equal to the number of soldiers in the row that $i$-th soldier see.

제한

예제 입력 1

4
178 180 170 190
LLLL

예제 출력 1

0 1 1 2

예제 입력 2

5
178 180 175 170 190
LLRLL

예제 출력 2

0 1 2 2 3

예제 입력 3

5
178 180 170 170 160
LLRLL

예제 출력 3

0 1 1 2 3

힌트

출처

Olympiad > Russian Olympiad in Informatics > Russia High School Programming Contest > Russia High School Programming Contest 2017 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /