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

24974번 - Apple Catching 다국어

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

문제

It's raining apples! At certain points in time, some number of apples will hit the number line. At certain points in time, some of Farmer John's cows will arrive on the number line and start catching apples.

If an apple hits the number line without a cow to catch it, it is lost forever. If a cow and an apple arrive at the same time, the cow catches it. Each cow can travel one unit per second. Once a cow catches a single apple, she exits the number line.

If FJ's cows collaborate optimally, how many apples can they catch in total?

입력

The first line contains $N$ (1ドル\le N\le 2\cdot 10^5$), the number of times apples hit the number line or FJ's cows appear.

The next $N$ lines each contain four integers $q_i,ドル $t_i,ドル $x_i,ドル and $n_i$ ($q_i\in \{1,2\}, 0\le t_i\le 10^9, 0\le x_i\le 10^9, 1\le n_i\le 10^3$).

  • If $q_i=1,ドル this means that $n_i$ of FJ's cows arrive on the number line at time $t_i$ at location $x_i$.
  • If $q_i=2,ドル this means that $n_i$ apples will hit the number line at time $t_i$ at location $x_i$.

It is guaranteed that all of the ordered pairs $(t_i,x_i)$ are distinct.

출력

The maximum number of apples FJ's cows may collectively catch.

제한

예제 입력 1

5
2 5 10 100
2 6 0 3
2 8 10 7
1 2 4 5
1 4 7 6

예제 출력 1

10

In this example, none of the 100ドル$ apples that land at time $t=5$ may be caught. Here is a way for 10ドル$ apples to be caught:

  • All six of FJ's cows that arrive at time $t=4$ catch one of the apples that land at time $t=8$.
  • One of FJ's cows that arrive at time $t=2$ catches one of the apples that land at time $t=8$.
  • Three of the remaining cows that arrive at time $t=2$ catch one of the apples that land at time $t=6$.

예제 입력 2

5
2 5 10 100
2 6 0 3
2 8 11 7
1 2 4 5
1 4 7 6

예제 출력 2

9

Here again, none of the apples that land at time $t=5$ may be caught. Furthermore, none of the cows that arrive at time $t=2$ may catch any of the apples that land at time $t=8$. Here is a way for 9ドル$ apples to be caught:

  • All six of FJ's cows that arrive at time $t=4$ catch one of the apples that land at time $t=8$.
  • Three of the remaining cows that arrive at time $t=2$ catch one of the apples that land at time $t=6$.

힌트

출처

Olympiad > USA Computing Olympiad > 2021-2022 Season > USACO 2022 US Open Contest > Gold 1번

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

출처

대학교 대회

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

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