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

19309번 - Gate 21 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB214433.333%

문제

You are participating in a ski race. It's rumored that an autograph of Serj Tankian is the grand prize.

Every racer must pass through $n$ gates numbered from 1 to $n$. The $i$-th gate consists of several equivalent checkpoints, which can be considered as points on a plane having coordinates $(i, j)$ for all integers $j$ between $l_i$ and $r_i,ドル inclusive. It's required to pass through exactly one checkpoint at every gate in increasing order of gate numbers.

Unfortunately, you are very bad at turning on skis. Thus, you would like to prepare a route for yourself which is a straight line passing through a single checkpoint at every gate. How many route options do you have?

입력

The first line of the input contains a single integer $n$ (2ドル \le n \le 2 \cdot 10^5$).

Each of the next $n$ lines contains two integers $l_i$ and $r_i$ (1ドル \le l_i \le r_i \le 10^9$).

출력

Output a single integer --- the number of valid straight routes you can take.

제한

예제 입력 1

3
1 3
2 3
1 5

예제 출력 1

6

힌트

In the example test case, all possible routes are:

  • $(1, 1) \rightarrow (2, 2) \rightarrow (3, 3)$;
  • $(1, 2) \rightarrow (2, 2) \rightarrow (3, 2)$;
  • $(1, 3) \rightarrow (2, 3) \rightarrow (3, 3)$;
  • $(1, 2) \rightarrow (2, 3) \rightarrow (3, 4)$;
  • $(1, 3) \rightarrow (2, 2) \rightarrow (3, 1)$;
  • $(1, 1) \rightarrow (2, 3) \rightarrow (3, 5)$.

출처

Camp > Petrozavodsk Programming Camp > Winter 2018 > Day 6: Gennady Korotkevich Contest 3, Grand Prix of Gomel G번

Contest > Open Cup > 2017/2018 Season > Stage 12: Grand Prix of Gomel G번

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

출처

대학교 대회

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

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