Logo
(追記) (追記ここまで)

31970번 - Trains 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB81403150.000%

문제

You have arrived in Vilnius and want to visit various cities in Lithuania.

Cities in Lithuania are located on a straight line and numbered from 1ドル$ to $N$ sequentially. Vilnius is assigned the number 1ドル$.

Each city has a train station with a single train route that operates from that station. You can only get on a train at the start of its route, though you can get off at any of its stops. Trains starting their route at the $i$-th city make a stop every $d_i$ cities, and their route consists of $x_i$ stops (not including the starting city). If $d_i = 0,ドル the trains operating from the $i$-th city are currently out of service, so you cannot get on them.

To be more precise, if you get on a train in the $i$-th city, you can get off the train in any city numbered $i + t \cdot d_i,ドル where 1ドル ≤ t ≤ x_i$. Note that since you only want to visit cities in Lithuania, you won't ride further than the $N$-th city, even if the train has more stops on its route.

You are going to visit some cities, using trains to travel between them. As you plan your trip, you start to wonder how many different options you have for your journey that starts at Vilnius. Two journeys are different if they make stops at different sequences of cities.

Calculate this number and print the answer modulo 10ドル^9 + 7$.

입력

The first line contains one integer $N$ – the number of cities.

Then $N$ lines follow. The $i$-th of them contains two integers $d_i$ and $x_i$ – the numbers describing the route starting in the $i$-th city.

출력

Output a single integer – the number of ways you can visit some of the $N$ cities taken modulo 10ドル^9 + 7$.

제한

  • 1ドル ≤ N ≤ 10^5$
  • 0ドル ≤ d_i ≤ 10^9$ (for each 1ドル ≤ i ≤ N$)
  • 0ドル ≤ x_i ≤ 10^9$ (for each 1ドル ≤ i ≤ N$)

서브태스크

번호배점제한
18

$n ≤ 15$.

213

$n ≤ 10^4$.

316

For all trains, $d_i = 1$.

434

For all trains, $x = 10^9$.

529

No additional contraints.

예제 입력 1

5
1 3
2 1
1 3
0 10
3 5

예제 출력 1

7

There are 7ドル$ possible journeys you could take:

  • 1ドル$
  • 1ドル \rightarrow 2$
  • 1ドル \rightarrow 2 \rightarrow 4$
  • 1ドル \rightarrow 3$
  • 1ドル \rightarrow 3 \rightarrow 4$
  • 1ドル \rightarrow 3 \rightarrow 5$
  • 1ドル \rightarrow 4$

힌트

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2024 C번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /