All submissions for this problem are available.
Each Justice Leaguer has some power, a number representing his strength. Every member can call some other members for help. The call for help can be cascaded. For example, x can call y and then, y can call z. The reach of a member is defined as the sum of the powers of all the members that can be called to help. Given the list of which members can call which members to help, estimate which member can assemble largest aggregate of powers.
The first line contains 2 integers - the number of members, n and the number of helper relations, m.
- The second line contains n integers, the ith integer A_i, representing the power of the ith member.
- The next m line contains 2 integers, u and v, denoting that u can call on v to help.
Output exactly one integer denoting the member's number who can assemble largest aggregate of powers.
- No member can call on himself for help, directly or indirectly
Let the aggregate of powers of members that your given Justice Leaguer can assemble be x and y be the sum of powers of all the members in that particular test file. Your score for that particular test file is then (x/y). Total score is sum of scores over all test files.
|Time Limit:||0.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions