RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0525

Apple Catching

Platinum II 플래티넘 II
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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?

Problem credits: Benjamin Qi

제약

Problem credits: Benjamin Qi

입력 형식

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
출력
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
출력
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\).
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2021-2022 > US Open > Gold

태그

평가 및 의견

Apple Catching

개요
출제자 난이도 Platinum II 플래티넘 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Apple Catching

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8