#624
Silver IV
Hungry Cow
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie is a hungry cow. Each day, for dinner, if there is a haybale in the barn, she will eat one haybale. Farmer John does not want Bessie to starve, so some days he sends a delivery of haybales, which arrive in the morning (before dinner). In particular, on day did_i, Farmer John sends a delivery of bib_i haybales (1di10141\leq d_i \leq 10^{14}, 1bi1091 \leq b_i \leq 10^9).

Compute the total number of haybales Bessie will eat during the first TT days.

입력

The first line contains NN and TT (1N1051 \le N \le 10^5, 1T10141 \le T \le 10^{14}).

The next NN lines each contain did_i and bib_i. It is additionally guaranteed that 1d1<d2<<dNT1\le d_1<d_2<\dots < d_N\le T.

출력

Output the number of haybales that Bessie will eat during the first TT days.

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

예제 입력 1

1 5
1 2

예제 출력 1

2

예제 입력 2

2 5
1 2
5 10

예제 출력 2

3

예제 입력 3

2 5
1 10
5 10

예제 출력 3

5

점수

Inputs 4-7: T105T \le 10^5Inputs 8-13: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Silver IV1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.