Curious Jury

시간 제한3초메모리 제한1024 MB

요약
각 팀이 벌점으로 s 또는 l을 고르며, 2^n가지 선택 전체에서 순위가 벌점과 같은 팀 수의 합을 구한다.
난이도

어려움10점 중 8점

유형
조합론, 정렬, 수학, 동적 계획법
정답자
아직 제출이 없습니다

문제

There are multiple ways to break ties based on submit time in competitive programming contests. In particular, the time penalty can either be the sum of all the times that you submit a correct solution (like in this contest!), or it can be the time that the last accepted submission of a team came in.

As a jury member of a prestigious team contest, you are really excited by "fixed points". These are places in the scoreboard where the rank of a particular team is equal to their penalty time. Because all teams solved all problems, the rank of a team is equal to the number of teams who had a strictly lower penalty time +1+ 1.

For each team, you know the sum of submit times of submissions ss, and a last submit time ll. The contest consists of more than one problem, so it must hold that l<sl < s for each team. Additionally, we assume that the sum of submit times does not exceed the number of teams.

For example, say the penalty times for teams A, B, and C are 11 minute, 22 minutes, and 11 minute, respectively. Teams A and C both share rank 11, because no other teams have a strictly lower penalty time. They both also have penalty time 11, so they both form a fixed point on the scoreboard. There are two other teams which have a strictly lower penalty time than team B, so team B has rank 33, and its penalty time is 22, so it does not constitute a fixed point. In this example, there are 22 fixed points.

For each team, you decide to arbitrarily pick between the two ways of calculating the penalty time, to make fixed points.

For a given way of picking the sum or last submit time for each team, define gg as the number of fixed points the scoreboard has.

Find the sum of gg over all ways of choosing penalty times.

입력

The input consists of:

  • One line with an integer nn (2≤n≤2⋅1052 \leq n\leq 2\cdot10^5), the number of participating teams.
  • nn lines with two integers ll and ss (1≤l<s≤n1 \leq l < s \leq n), the last submit time and the sum of submit times for a team.

출력

Output the sum of gg, the number of fixed points, over all 2n2^n ways of choosing penalty times.

Because the answer can be huge, output the answer modulo the prime 109+710^9+7.

예제2

  1. 예제 1

    입력
    3
    1 2
    2 3
    1 3
    
    예상 출력
    16
    
  2. 예제 2

    입력
    10
    1 6
    2 7
    3 8
    1 2
    5 9
    9 10
    1 10
    2 8
    3 4
    4 5
    
    예상 출력
    4752