/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 233 点
問題文
高橋君は数直線上の座標 0 に立っています。これから N 回移動します。 i 回目の移動は文字 D_i と整数 X_i で表され、 D_i が R なら正の方向に X_i 進み、 L なら負の方向に X_i 進みます。
各移動が終わった直後の高橋君の座標を、順番に出力してください。
制約
- 1 \leq N \leq 100
- D_i は
LまたはR - 1 \leq X_i \leq 1000
- N と X_i は整数
入力
入力は以下の形式で標準入力から与えられる。
N D_1 X_1 D_2 X_2 \vdots D_N X_N
- 1 行目には、移動の回数 N が与えられる。
- 2 行目から N 行にわたり、 1 + i 行目には i 回目の移動の方向 D_i と距離 X_i がスペース区切りで与えられる。
出力
N 行出力せよ。 i 行目には i 回目の移動が終わった直後の座標を出力せよ。
入力例 1
3 R 5 L 2 R 4
出力例 1
5 3 7
入力例 2
1 R 10
出力例 2
10
入力例 3
4 R 3 R 3 L 6 R 1
出力例 3
3 6 0 1
入力例 4
3 R 5 L 2 R 1
出力例 4
5 3 4
入力例 5
1 R 11
出力例 5
11
Score : 233 pts
Problem Statement
Takahashi is standing at coordinate 0 on a number line. He will make N moves. The i-th move is represented by a character D_i and an integer X_i. If D_i is R, he moves X_i in the positive direction; if D_i is L, he moves X_i in the negative direction.
Print Takahashi's coordinate immediately after each move, in order.
Constraints
1 ≤ N ≤ 100D_iis eitherLorR1 ≤ X_i ≤ 1000NandX_iare integers
Input
The input is given from standard input in the following format:
N D_1 X_1 D_2 X_2 \vdots D_N X_N
- The first line contains the number of moves
N. - For each
1 ≤ i ≤ N, the(i + 1)-th line contains the directionD_iand distanceX_iof thei-th move, separated by a space.
Output
Print N lines. The i-th line should contain Takahashi's coordinate immediately after the i-th move.
Sample Input 1
3 R 5 L 2 R 4
Sample Output 1
5 3 7
Sample Input 2
1 R 10
Sample Output 2
10
Sample Input 3
4 R 3 R 3 L 6 R 1
Sample Output 3
3 6 0 1
Sample Input 4
3 R 5 L 2 R 1
Sample Output 4
5 3 4
Sample Input 5
1 R 11
Sample Output 5
11