시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 (추가 시간 없음) | 1024 MB | 7 | 5 | 5 | 83.333% |
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:
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$.
S
' or 'B
'.3 3 999999999 0 2 4 2 BS
2 5 9
10 810737462 262894941 12979345 90139935 834123271 768745833 928886601 144082546 35547099 840309069 10 854737038 93768450 848842263 62613614 800833082 316988396 203584286 283415773 762732633 756024517 SBSSSBSSBS
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: