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

21916번 - Neo-Robin Hood 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 256 MB230706733.500%

문제

There are $n$ aspiring politicians in Neverland. They are wealthy, but not wealthy enough to gain political influence. Since Neverland is a financially transparent haven, we know the bank statements of each politician: the $i$-th politician (1ドル \le i \le n$) has $m_i$ dollars, and needs $p_i$ more dollars to achieve his political goals.

You are the infamous modern superhero Neo-Robin Hood. You earn your living by stealing from the rich and wealthy, in order to help... well, whoever promises to help you back. For each of the $n$ politicians you can chose to do one of the following:

  1. Steal his $m_i$ dollars;
  2. Do nothing to him;
  3. Help him gain political influence, by giving him $p_i$ dollars.

But your services don’t come for free. Once you help a politician gain political influence, he is bound to help you cover-up one of your thefts so that you won’t get in trouble – for instance, by providing an alibi. In turn, you are also bound to not steal his money in the future.

Initially you start with no money. Your task is to rob as many politicians as possible; however, you can’t afford to get caught, so you need a politician to account for each crime you commit.

What is the maximum number of people you can rob?

입력

The first line of the input contains a positive integer $n$ (1ドル \le n \le 100,000円$), the number of politicians. The second line of the input contains $n$ positive integers $m_i$ (1ドル \le m_i \le 10^9,ドル for all 1ドル \le i \le n$). The third line of the input contains $n$ positive integers $p_i$ (1ドル \le p_i \le 10^9,ドル for all 1ドル \le i \le n$).

출력

Output a single non-negative integer, the maximum number of people that you can steal from.

Note that you do not have to maximize your own wealth, but rather the number of people that you are stealing from.

제한

예제 입력 1

5
2 3 4 5 6
1 2 3 4 5

예제 출력 1

2

예제 입력 2

4
1 2 4 2
5 6 9 7

예제 출력 2

0

예제 입력 3

4
9 19 6 5
20 3 16 19

예제 출력 3

1

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2020 L번

Contest > Open Cup > 2020/2021 Season > Stage 17: Grand Prix of Southern Europe L번

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

출처

대학교 대회

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

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