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

24846번 - Army of Clones 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 512 MB76474261.765%

문제

The army of $x$ clones sneaked into the spaceship "Death Star" to help Luke Skywalker battling with Darth Vader. The spaceship consists of $n$ rooms and $m$ bidirectional passages between them. The clones start in the room 1 and want to go to the room $n,ドル where Luke is.

However every room is guarded by droids, room $i$ is guarded by $a_i$ droids. When the clones appear in the room, the battle between them and the droids starts. If the number of clones is greater than the number of droids, the clones will kill all the droids and all the clones will stay alive. Otherwise the clones will kill all droids as well, but they will lose half of the army: if there are $x$ clones at the beginning of the battle, then there will be $\left \lfloor \frac{x}{2} \right \rfloor$ clones at the end of battle, rounded down. The clones have to battle in all rooms they would visit, including rooms 1 and $n$.

Help the captain of the army to count the maximum number of clones that can come from the room 1 to the room $n$ .

입력

The first line contains two integers $n$ and $m$ --- number of rooms and passages in "Death Star" (1ドル \le n, m \le 2 \cdot 10^5$).

The following $m$ lines describe passages: the $i$-th passage is described by two integers $u_i$ and $v_i$ --- the rooms that are connected by the passage (1ドル \le u_i, v_i \le n,ドル $u_i \neq v_i$). It is guaranteed that every pair of rooms is connected by at most one passage.

The next line contains an integer $x$ --- the number of clones in the army (1ドル \le x \le 10^9$).

The last line contains $n$ integers $a_1, a_2, \ldots, a_n$ --- the number of droids in the rooms (1ドル \le a_i \le 10^9$).

출력

Print a single integer --- the maximum number of clones that can go from room 1 to room $n$. If there is no path to follow, so that at least one clone survives, print 0.

제한

예제 입력 1

4 4
1 2
1 3
2 4
3 4
7
10 2 3 1

예제 출력 1

3

예제 입력 2

4 4
1 2
1 3
2 4
3 4
7
10 3 3 1

예제 출력 2

0

힌트

출처

Olympiad > Russian Olympiad in Informatics > Russia High School Programming Contest > Russia High School Programming Contest 2021 D번

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

출처

대학교 대회

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

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