Topical
면접 대비시간 제한1초메모리 제한1024 MB
각 모듈은 k개 주제에 대한 최소 지식 요건을 만족해야 이수할 수 있고 이수하면 지식이 늘어난다. 어떤 순서로 이수할 때 완료할 수 있는 모듈 수의 최댓값을 구한다.
문제
Benson the Rabbit is attending pilot school!
He has modules to complete, numbered from to . There are topics in flying numbered from to . As Benson is new to flying, he starts with zero knowledge in each topic.
Each of these modules have a knowledge requirement to complete them. In particular, to complete module , Benson requires at least knowledge of topic for all topics .
Completing a module also allows Benson to gain knowledge in some topics. After completing module , he will gain knowledge in topic .
Formally, let Benson’s knowledge in topic be . Initially, for all . He can only complete a module if for every topic . After completing module , the value of increases by for each topic .
Benson may complete the modules in any order, but each module may only be completed at most once. Help Benson determine the maximum number of modules he can complete.
입력
The first line of input contains space-separated integers, and .
Then, lines will follow. The -th () of these lines contains spaced integers , denoting the knowledge requirements to complete module .
Another lines follow. The -th () of these lines contains spaced integers , denoting the knowledge gained after completing module .
출력
The output should contain one integer, the maximum number of modules Benson can complete.
제한
- (for all and ).