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

27849번 - Hungry Cow 다국어

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

문제

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 $d_i,ドル Farmer John sends a delivery of $b_i$ haybales (1ドル\leq d_i \leq 10^{14},ドル 1ドル \leq b_i \leq 10^9$).

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

입력

The first line contains $N$ and $T$ (1ドル \le N \le 10^5,ドル 1ドル \le T \le 10^{14}$).

The next $N$ lines each contain $d_i$ and $b_i$. It is additionally guaranteed that 1ドル\le d_1<d_2<\dots < d_N\le T$.

출력

Output the number of haybales that Bessie will eat during the first $T$ 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

Two haybales arrive on the morning of day 1ドル$. Bessie eats one haybale for dinner on day 1ドル$ and another haybale on day 2ドル$. On days 3ドル \ldots 5,ドル there are no more haybales for Bessie to eat. In total, Bessie eats 2ドル$ haybales during the first 5ドル$ days.

예제 입력 2

2 5
1 2
5 10

예제 출력 2

3

Two haybales arrive on the morning of day 1ドル$. Bessie eats one haybale on days 1ドル$ and 2ドル$. There are no haybales for Bessie to eat on days 3ドル$ and 4ドル$. On the morning of day 5ドル,ドル 10ドル$ haybales arrive. Bessie eats one haybale for dinner on day 5ドル$. In total, Bessie eats 3ドル$ haybales during the first 5ドル$ days.

예제 입력 3

2 5
1 10
5 10

예제 출력 3

5

10ドル$ haybales arrive on the morning of day 1ドル$. Bessie eats one haybale on days 1ドル \ldots 4$. On the morning of day 5ドル,ドル another 10ドル$ haybales arrive, meaning there are 16ドル$ haybales in the barn. For dinner on day 5ドル,ドル Bessie eats another haybale. In total, Bessie eats 5ドル$ haybales during the first 5ドル$ days.

힌트

출처

Olympiad > USA Computing Olympiad > 2022-2023 Season > USACO 2023 February Contest > Bronze 1번

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

출처

대학교 대회

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

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