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

11161번 - Negative People in Da House 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB121467261857.116%

문제

The following math joke is presented for your amusement: Two mathematicians sit in a car outside a house. Two people enter the house. Then, three people are observed going out of the house. One of the mathematicians exclaim: If one person is to enter now, the house will be empty!

Since you have very little sense of humor, you are to write a program that will calculate the minimum number of people there must have been there to begin with. In other words, given a sequence of groups of people leaving and entering the house, output the minimum number of people there must have been before you started stalking. After writing this program, your mathematician friend will leave you, as well as their math department, to start a company specializing in joke-telling and stalking.

입력

The first line of the input consists of a single integer T, the number of test cases. Each of the following T cases has two parts: First, a line containing a single integer M. Then follows M lines with two integers P1 and P2 separated by a space, where the first one contains the number of people entering the house, then the number of people leaving the house. Note that these are two events: First, P1 people enter the house, then P2 people leave the house.

  • 0 < T ≤ 50
  • 0 < M ≤ 100
  • 0 ≤ P1, P2 ≤ 1000

출력

Output the minimum number of people that would have to have been inside the house at the beginning.

제한

예제 입력 1

1
3
3 5
3 4
1 0

예제 출력 1

3

힌트

출처

Contest > IDI Open Contest > IDI Open 2013 D번

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

출처

대학교 대회

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

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