ساعت
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
ساعت
دقیقه
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
دقیقه
ثانیه
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
ثانیه
  • محدودیت زمان: ۲ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Ali hosts a yearly chess tournament for CafeBazaar’s Shab-e Yalda festival. In a chess tournament, each pair of participants play a game against each other exactly once. Moreover, players are granted one point for a win, a half point for a draw, and no points for a loss toward their tournament score. Danial has built a system to predict the result of Ali’s tournament. Based on experience, he has assigned an opening skill and an ending skill to each of n participants in the tournament. For the ii-th participant, let us denote the former with oio_i and the latter with eie_i. In a game between the ii-th and jj-th participants, Danial decides the result of the game according to the following rules:

  1. If oi>ojo_i > o_j and ei>eje_i > e_j, then the ii-th participant wins the game.
  2. If oj>oio_j > o_i and ej>eie_j > e_i, then the jj-th participant wins the game.
  3. Otherwise, the game ends in a draw.

To make the tournament more exciting, Ali wants to invite Danial to join the other nn participants in the tournament. Since Danial has no prior experience in chess, he decides to practice for the tournament. Based on the amount of training, Danial can end up with any opening and ending skill. However, Danial has promised Ali that he will train in such a way that his opening skill will be different from the opening skill of the other participants. He will also keep his ending skill different from the ending skill of the other participants.

For his advertisement campaign, Ali wants to know the number of distinct possible final scores that Danial might get based on Danial’s rules mentioned above. For example, Danial can achieve the scores 0,1.5,2.5,3,4,0, 1.5, 2.5, 3, 4, and 55 in the sample. For instance, the score 33 is obtained by setting the opening and ending skills of Danial to be 1.51.5. Since Ali and all other CafeBazaar programmers are busy planning the event, he has turned to you for help. Write a program to calculate this value

ورودی

The first line of the input contains a single integer nn (1n200,0001 \leq n \leq 200 , 000), the number of participants. The ii-th line of the next nn lines contains two integers oio_i and eie_i (1oi,ein1 \leq o_i , e_i \leq n), the opening and ending skills of the ii-th participant, respectively. Note that the limits for opening and ending skills do not apply to Danial’s opening and ending skills. More specifically, Danial’s opening and ending skills can be any real numbers

خروجی

In the only line of the output, print the number of distinct possible final scores for Danial.

مثال

ورودی نمونه ۱

5
1 1
1 2
1 1
2 1
2 2
Plain text

خروجی نمونه ۱

6
Plain text

ارسال پاسخ برای این سؤال
فایلی انتخاب نشده است.