시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 773 412 387 55.050%

문제

상근이는 남산1호터널의 입구와 출구에서 1분에 통과하는 차량의 수를 조사했다. 이때, 터널에 차량이 가장 많이 있었을 때, 몇 대 있었는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 조사한 시간 n이 주어진다. 둘째 줄에는 조사를 시작할 때, 터널 안에 들어있는 차량의 수 m이 주어진다. 다음 n개 줄의 i번째 줄(i = 1 ~ n)의 정보는 조사를 시작한지 (i-1)분이 경과한 시점부터 i분 경과할 때 까지 1분에 입구를 통과한 차의 수와 출구를 통과한 차의 수이다. n은 10000보다 작거나 같고, 1분에 통과하는 차량의 수는 100이하이다.

출력

조사 시작하고 j분이 지난 시점 (j = 0~n)에서 터널 안에 있는 차량의 수를 Sj라고 하자. 이때, Sj의 최댓값을 출력한다. 만약, 터널 안에 있는 차량의 수가 0보다 작은 경우가 한 번 이라도 발생한다면 0을 출력한다.

예제 입력 1

3
2
2 3
2 3
4 1

예제 출력 1

3
W3sicHJvYmxlbV9pZCI6IjU2MTIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQxMzBcdWIxMTBcdWM3NTggXHVjNzg1XHVhZDZjXHVjNjQwIFx1Y2Q5Y1x1YWQ2YyIsImRlc2NyaXB0aW9uIjoiPHA+XHVjMGMxXHVhZGZjXHVjNzc0XHViMjk0IFx1YjBhOFx1YzBiMDFcdWQ2MzhcdWQxMzBcdWIxMTBcdWM3NTggXHVjNzg1XHVhZDZjXHVjNjQwIFx1Y2Q5Y1x1YWQ2Y1x1YzVkMFx1YzExYyAxXHViZDg0XHVjNWQwIFx1ZDFiNVx1YWNmY1x1ZDU1OFx1YjI5NCBcdWNjMjhcdWI3YzlcdWM3NTggXHVjMjE4XHViOTdjIFx1Yzg3MFx1YzBhY1x1ZDU4OFx1YjJlNC4gXHVjNzc0XHViNTRjLCBcdWQxMzBcdWIxMTBcdWM1ZDAgXHVjYzI4XHViN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