Movatterモバイル変換


[0]ホーム

URL:


Logo

33205번 -CF Duels서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초2048 MB0000.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:

  • There will be a total of $N$ 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 $N$ players to the $N$ duels.

As the manager of the first football team, you have the following information:

  • $N$ integers, representing the skill levels of your team's players
  • $N$ 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 $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 ≤ N ≤ 5 \cdot 10^4$.
  • $1 ≤ a_i , b_i , p_i ≤ 10^6$ for all ($1 ≤ i ≤ N$).
  • Additionally, the skill levels of all the players are distinct. In other words for any $(i, j)$ $a_i \ne b_j $ And for any $(i, j)$ ($i \ne j$) $a_i \ne a_j$ and $b_i \ne b_j$.

서브태스크

번호배점제한
112

$p_i = 1$ for all $i$, and $N ≤ 10$

216

$p_i = 1$ for all $i$

314

The answer is either $0$ or $1$

418

The answer is either $-1$ or $N - 1$

510

$N ≤ 5$

630

No additional constraints

예제 입력 1

51 5 4 3 15 9 3 12 81 10 4 2 6

예제 출력 1

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$unknownunknown

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$.

예제 입력 2

66 1 21 22 23 241 12 6 8 10 112 3 4 5 7 9

예제 출력 2

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.

예제 입력 3

31 1 33 4 62 1 7

예제 출력 3

0

예제 입력 4

31 1 33 4 62 1 5

예제 출력 4

-1

힌트

출처

Olympiad > European Junior Olympiad in Informatics > eJOI 2024 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.

출처

대학교 대회

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


[8]ページ先頭

©2009-2025 Movatter.jp