/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 166 点
問題文
高橋君はカードゲームのデッキを組んでいます。デッキには N 種類のカードが必要で、 i 種類目のカードはちょうど A_i 枚必要です。高橋君は現在、 i 種類目のカードを B_i 枚持っています。
各種類について、あと何枚買えば必要な枚数が揃うかを求めてください。すでに必要な枚数以上持っている場合は 0 を出力してください。
制約
- 1 \leq N \leq 100
- 1 \leq A_i \leq 1000
- 0 \leq B_i \leq 1000
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
N A_1 B_1 A_2 B_2 \vdots A_N B_N
- 1 行目には、カードの種類数 N が与えられる。
- 2 行目から N 行にわたり、 1 + i 行目には i 種類目のカードの必要枚数 A_i と現在の枚数 B_i がスペース区切りで与えられる。
出力
N 行出力せよ。 i 行目には i 種類目のカードをあと何枚買えばよいかを出力せよ。
入力例 1
3 4 1 2 2 3 0
出力例 1
3 0 3
入力例 2
1 10 3
出力例 2
7
入力例 3
2 5 5 7 2
出力例 3
0 5
入力例 4
2 1 0 2 1
出力例 4
1 1
入力例 5
2 5 0 7 2
出力例 5
5 5
Score : 166 pts
Problem Statement
Takahashi is building a deck for a card game. The deck requires N types of cards, and exactly A_i cards of the i-th type are needed. Takahashi currently has B_i cards of the i-th type.
For each type, determine how many more cards he needs to buy to have the required number. If he already has at least the required number, print 0.
Constraints
- 1 \leq N \leq 100
- 1 \leq A_i \leq 1000
- 0 \leq B_i \leq 1000
- All input values are integers.
Input
The input is given from standard input in the following format:
N A_1 B_1 A_2 B_2 \vdots A_N B_N
- The first line contains N, the number of card types.
- For each of the following N lines, the (1+i)-th line contains the required number A_i and current number B_i of cards of the i-th type, separated by a space.
Output
Print N lines. On the i-th line, print how many more cards of the i-th type Takahashi needs to buy.
Sample Input 1
3 4 1 2 2 3 0
Sample Output 1
3 0 3
Sample Input 2
1 10 3
Sample Output 2
7
Sample Input 3
2 5 5 7 2
Sample Output 3
0 5
Sample Input 4
2 1 0 2 1
Sample Output 4
1 1
Sample Input 5
2 5 0 7 2
Sample Output 5
5 5