시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 351 114 87 39.013%

문제

x축 위에 원이 N개 있다. 원은 서로 교차하지 않는다. 하지만, 접할 수는 있다.

원으로 만들어지는 영역이 몇 개인지 구하는 프로그램을 작성하시오.

영역은 점의 집합으로 모든 두 점은 원을 교차하지 않는 연속되는 곡선으로 연결될 수 있어야 한다.

입력

첫째 줄에 원의 개수 N(1 ≤ N ≤ 300,000)이 주어진다.

다음 N개 줄에는 각 원의 정보 xi와 ri가 주어진다. xi는 원의 중심 좌표이며, ri는 반지름이다. (-109 ≤ xi ≤ 109, 1 ≤ ri ≤ 109)

입력으로 주어지는 원은 항상 유일하다.

출력

첫째 줄에 원으로 인해서 만들어지는 영역의 개수를 출력한다.

예제 입력 1

4
7 5
-9 11
11 9
0 20

예제 출력 1

6
W3sicHJvYmxlbV9pZCI6IjEwMDAwIiwicHJvYmxlbV9sYW5nIjoiMCIsInRpdGxlIjoiXHVjNmQwIFx1YzYwMVx1YzVlZCIsImRlc2NyaXB0aW9uIjoiPHA+eFx1Y2Q5NSBcdWM3MDRcdWM1ZDAgXHVjNmQwXHVjNzc0IE5cdWFjMWMgXHVjNzg4XHViMmU0LiBcdWM2ZDBcdWM3NDAgXHVjMTFjXHViODVjIFx1YWQ1MFx1Y2MyOFx1ZDU1OFx1YzljMCBcdWM1NGFcdWIyOTRcdWIyZTQuIFx1ZDU1OFx1YzljMFx1YjljYywgXHVjODExXHVkNTYwIFx1YzIxOFx1YjI5NCBcdWM3ODhcdWIyZTQuPFwvcD5cclxuXHJcbjxwPlx1YzZkMFx1YzczY1x1Yjg1YyBcdWI5Y2NcdWI0ZTRcdWM1YjRcdWM5YzBcdWIyOTQgXHVjNjAxXHVjNWVkXHVjNzc0IFx1YmE4NyBcdWFjMWNcdWM3NzhcdWM5YzAgXHVhZDZjXHVkNTU4XHViMjk0IFx1ZDUwNFx1Yjg1Y1x1YWRmOFx1YjdhOFx1Yzc0NCBcdWM3OTFcdWMx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TsgMTA8c3VwPjk8XC9zdXA+KSwgdGhlIG51bWJlciB4PHN1Yj5pPFwvc3ViPiByZXByZXNlbnRpbmcgdGhlIHggY29vcmRpbmF0ZSBvZiB0aGUgaTxzdXA+dGg8XC9zdXA+IGNpcmNsZSBhbmQgdGhlIG51bWJlciByPHN1Yj5pPFwvc3ViPiByZXByZXNlbnRpbmcgdGhlIHJhZGl1cyBvZiB0aGUgaTxzdXA+dGg8XC9zdXA+IGNpcmNsZS4mbmJzcDs8XC9wPlxyXG5cclxuPHA+QWxsIHRoZSBjaXJjbGVzIGluIHRoZSBpbnB1dCB3aWxsIGJlIHVuaXF1ZS4mbmJzcDs8XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5UaGUgZmlyc3QgYW5kIG9ubHkgbGluZSBvZiBvdXRwdXQgbXVzdCBjb250YWluIHRoZSByZXF1aXJlZCBudW1iZXIgZnJvbSB0aGUgdGFzay4mbmJzcDs8XC9wPlxyXG5cclxuPHA+Jm5ic3A7PFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

Contest > Croatian Open Competition in Informatics > COCI 2013/2014 > Contest #6 4번

  • 데이터를 추가한 사람: Acka
  • 문제를 번역한 사람: baekjoon