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

23476번 - Cookies 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 1024 MB177753.846%

문제

You are to hold a cookie party! You have prepared $N$ cookies numbered from 1ドル$ through $N$. The sweetness of the cookie $i$ is $A_i$. You expect that $M$ children numbered from 1ドル$ to $M$ will attend the party. All of them will bring their homemade cookies, and the child $i$ will bring a cookie of sweetness $B_i$. Besides, you know the taste preference of each child. The child $i$ loves sweet cookies if $S_i=$S and loves bitter cookies if $S_i=$B.

The party will proceed in the following manner:

  • First, you are given an integer $k$ and put cookies 1,2,ドル\cdots,k$ on the table.
  • Then, children 1,2,ドル\cdots,M,ドル in this order, come to the table. When the child $i$ comes to the table, the child first put his/her homemade cookie on the table. Then, if the child loves sweet cookies, he/she eats the sweetest cookie (a cookie with the largest sweetness) on the table. If the child loves bitter cookies, he/she eats the bitterest cookie (a cookie with the smallest sweetness) on the table. Note that each child eats exactly one cookie, and a child may eat his/her cookie.
  • Finally, you eat all the cookies left on the table.

You have not yet decided the value of $k$. For each integer $k=1,2,\cdots,N,ドル find the sum of the sweetness of cookies you will eat.

Note that only after you get the answer for $k=i$ can you know the value of $A_{i+1}$. See the input section for more details.

입력

Input is given from Standard Input in the following format:

$N$

$A'_1$ $A'_2$ $\cdots$ $A'_N$

$M$

$B_1$ $B_2$ $\cdots$ $B_M$

$S$

Here $A'_i$ is the encrypted value of $A_i,ドル and the real value can be calculated as $A_i=(A'_i+lastans \mod 10^9),ドル where $lastans$ denotes the answer for $k={i-1}$ if $i>1$ and 0ドル$ if $i=1$.

출력

Print $N$ integers in one line. The $i$-th integer should be the sum of the sweetness of cookies you will eat when $k=i$.

제한

  • 1ドル \leq N \leq 2 \times 10^5$
  • 0ドル \leq A_i \leq 10^9-1$
  • 0ドル \leq A'_i \leq 10^9-1$ (see the input section for the definition of this variable)
  • 1ドル \leq M \leq 2 \times 10^5$
  • 0ドル \leq B_i \leq 10^9-1$
  • $|S|=M$
  • $S_i$ is either 'S' or 'B'.
  • All values in input are integers.

예제 입력 1

3
3 999999999 0
2
4 2
BS

예제 출력 1

2 5 9

예제 입력 2

10
810737462 262894941 12979345 90139935 834123271 768745833 928886601 144082546 35547099 840309069
10
854737038 93768450 848842263 62613614 800833082 316988396 203584286 283415773 762732633 756024517
SBSSSBSSBS

예제 출력 2

756024517 959608803 1243024576 1560012972 1893177483 2287313726 2503514053 3151110652 3337768403 3515845875

노트

In first sample, $A=(3,1,5)$.

When $k=2,ドル the party proceeds as follows:

  • You put 2ドル$ cookies of sweetness 3ドル$ and 1ドル$.
  • The child 1ドル$ puts the cookie of sweetness 4ドル$ and eats the cookie of sweetness 1ドル$.
  • The child 2ドル$ puts the cookie of sweetness 2ドル$ and eats the cookie of sweetness 4ドル$.
  • You eat cookies of sweetness 2ドル$ and 3ドル$.

출처

Contest > Open Cup > 2019/2020 Season > Stage 15: Grand Prix of Tokyo A번

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

출처

대학교 대회

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

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