시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 698 379 355 55.469%

문제

상근이는 남산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+XHVjMGMxXHVhZGZjXHVjNzc0XHViMjk0IFx1YjBhOFx1YzBiMDFcdWQ2MzhcdWQxMzBcdWIxMTBcdWM3NTggXHVjNzg1XHVhZDZjXHVjNjQwIFx1Y2Q5Y1x1YWQ2Y1x1YzVkMFx1YzExYyAxXHViZDg0XHVjNWQwIFx1ZDFiNVx1YWNmY1x1ZDU1OFx1YjI5NCBcdWNjMjhcdWI3YzlcdWM3NTggXHVjMjE4XHViOTdjIFx1Yzg3MFx1YzBhY1x1ZDU4OFx1YjJlNC4gXHVjNzc0IFx1YjU0YywgXHVkMTMwXHViMTEwXHVjNWQwIFx1Y2MyOFx1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