시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 2048 MB | 0 | 0 | 0 | 0.000% |
Two football teams, each consisting of exactly $N$ 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 $1$ vs $1$ format:
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 $N$ players to the $N$ duels.
As the manager of the first football team, you have the following information:
As the manager, you also sent a scout to visit each stadium. The scout visits the stadiums in increasing order from $1$ to $N$, meaning he will visit stadium $1$ first, then stadium $2$, and will end at stadium $N$. After the scout visits stadium $i$, he will give you information regarding the skill level of the opposing team's duelist at stadium $i$.
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 $N$ ($1 ≤ N ≤ 5 \cdot 10^4$), denoting the number of duels, players per team and stadiums.
The second line will contain $N$ integers $p_1 , p_2 , …, p_N$ ($1 ≤ p_i ≤ 10^6$), representing the prize money offered by stadiums $1, 2, \dots , N$, respectively.
The third line contains $N$ integers $b_1 , b_2 , \dots , b_N$ ($1 ≤ b_i ≤ 10^6$), $b_i$ representing the skill level reported by the scout of the opponent player in stadium $i$. (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 $N$ integers $a_1 , a_2 , \dots , a_N$ ($1 ≤ a_i ≤ 10^6$), 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 $0$ in case you immediately know your team will be the champion in any case, or $-1$ if you can not find a winning strategy even after you have information of all the $N$ stadiums.
번호 | 배점 | 제한 |
---|---|---|
1 | 12 | $p_i = 1$ for all $i$, and $N ≤ 10$ |
2 | 16 | $p_i = 1$ for all $i$ |
3 | 14 | The answer is either $0$ or $1$ |
4 | 18 | The answer is either $-1$ or $N - 1$ |
5 | 10 | $N ≤ 5$ |
6 | 30 | No additional constraints |
51 5 4 3 15 9 3 12 81 10 4 2 6
3
For the first test case, after the scout shares information of stadiums $1$ and $2$, you are not guaranteed to be the champion. The reason is, in case the opponent assigns the players in the following way:
Stadium | $1$ | $2$ | $3$ | $4$ | $5$ |
---|---|---|---|---|---|
Prize money | $1$ | $5$ | $4$ | $3$ | $1$ |
Opponent's player skill level | $5$ | $9$ | $8$ | $12$ | $3$ |
Your best option is to achieve a draw:
Stadium | $1$ | $2$ | $3$ | $4$ | $5$ |
---|---|---|---|---|---|
Your player's skill level | $6$ | $10$ | $1$ | $2$ | $4$ |
You will win the matches in the stadiums $1$, $2$ and $5$, obtaining a prize money sum of $1 + 5 + 1 = 7$, and your opponent will win matches in stadiums $3$ and $4$, obtaining a sum of $4 + 3 = 7$ as well.
After the scout shares information of stadiums $1$, $2$ and $3$, you can be certain you will be the champion. The reason is, in case the opponent assigns the players in the following way:
Stadium | $1$ | $2$ | $3$ | $4$ | $5$ |
---|---|---|---|---|---|
Prize money | $1$ | $5$ | $4$ | $3$ | $1$ |
Opponent's player skill level | $5$ | $9$ | $3$ | unknown | unknown |
The two options of the opponent are:
Option $1$ | |||||
---|---|---|---|---|---|
Stadium | $1$ | $2$ | $3$ | $4$ | $5$ |
Prize money | $1$ | $5$ | $4$ | $3$ | $1$ |
Opponent's player skill level | $5$ | $9$ | $3$ | $12$ | $8$ |
Your player's skill level | $6$ | $10$ | $4$ | $1$ | $2$ |
Option $2$ | |||||
---|---|---|---|---|---|
Stadium | $1$ | $2$ | $3$ | $4$ | $5$ |
Prize money | $1$ | $5$ | $4$ | $3$ | $1$ |
Opponent's player skill level | $5$ | $9$ | $3$ | $8$ | $12$ |
Your player's skill level | $6$ | $10$ | $4$ | $1$ | $2$ |
We can notice that in both cases our team will win matches in stadiums $1$, $2$ and $3$, obtaining a total sum of prize money equal to $1 + 5 + 4 = 10$, and the opponent will obtain a total sum of prize money equal to $3 + 1 = 4$. And, since $10 > 4$, we can be certain we win in both these cases so the minimum answer is $3$.
66 1 21 22 23 241 12 6 8 10 112 3 4 5 7 9
2
For the second sample, it can be proven that after the scout provides information for stadiums $1$ and $2$ you will, for the first time, be certain to become the champion. However, unlike in the first sample, you won’t have a fixed winning assignment. Instead, for the opponent’s varying assignments in stadiums $3$, $4$, $5$, $6$ you need to have a different response strategy to win the championship.
31 1 33 4 62 1 7
0
31 1 33 4 62 1 5
-1