CF Duels
시간 제한2초메모리 제한2048 MB
상대 선수의 능력치를 앞에서부터 몇 개나 알아야 우리 팀의 우승을 보장하는 배정이 가능한지 최소 개수를 구한다.
문제
Two football teams, each consisting of exactly players, from Chisinau, the capital of Moldova, hold a set of duels (Chisinau Football Duels). To make it interesting, they organize the football match-ups in the following vs format:
- There will be a total of duels, each held in a different stadium.
- Each duel will have exactly one player from each of the two teams.
- Each player will take part in exactly one duel.
- Each stadium will provide a certain amount of prize money for the winner of the respective duel.
- The player with the higher skill level wins the duel. It is guaranteed that there is always a player with a higher skill level.
The champion is the team that has obtained a strictly greater amount of prize money than the opponent team after all the matches. In case of an equal obtained prize money, there is no champion.
You are the manager of the first football team, and your job is to strategically assign your players to the duels.
As the manager of the first football team, you have the following information:
- integers, representing the skill levels of your team's players
- integers, representing the skill levels of the opposing team's players
As the manager, you also sent a scout to visit each stadium. The scout visits the stadiums in increasing order from to , meaning he will visit stadium first, then stadium , and will end at stadium . After the scout visits stadium , he will give you information regarding the skill level of the opposing team's duelist at stadium .
Possibly, after the scout visits some stadiums, you can already foresee your team emerging as a champion. In other words, there is a possibility that, after your scout visits some stadiums, you will be certain that you can become the champion. You may still need to wait for the scout to visit the rest of the stadiums in order to be able to build an assignment for your team.
Your task is to find out the minimal number of stadiums the scout has to visit for you to be certain about that your team securing the championship, or figure out that it's impossible to become the champion.
입력
The first line of input will contain the integer (), denoting the number of duels, players per team and stadiums.
The second line will contain integers (), representing the prize money offered by stadiums , respectively.
The third line contains integers (), representing the skill level reported by the scout of the opponent player in stadium . (Note that this information already contains the skill levels of each of the players in the opponent team, so they are not given once again to remove redundancy).
The fourth line contains integers (), representing the skill levels of the players in your team.
출력
Output a single integer - the minimum number of stadiums you need information about to be certain your team can be the champion.
Additionally, you should output in case you immediately know your team will be the champion in any case, or if you can not find a winning strategy even after you have information of all the stadiums.
제한
- .
- for all ().
- Additionally, the skill levels of all the players are distinct. In other words for any And for any () and .