Submission #57461586


Source Code Expand

N = gets.to_i
E = Array.new(N){{}}
(N-1).times{
	u,v,l = gets.split.map(&:to_i)
	u,v,l = u-1,v-1,l+l
	E[u][v] = l
	E[v][u] = l
}
B = [0]*N
F = lambda{|v,p,v2p|
	E[v].each{|c,l|
		F[c,v,l] if c!=p
	}
	B[v] += v2p
	B[v],B[p] = B[p],B[v] if B[p]<B[v]
}
F[0,0,0]

s = 0
puts B.sort.reverse.map{ s += _1 }

Submission Info

Submission Time
Task G - As far as possible
User ds14050
Language Ruby (ruby 3.2.2)
Score 600
Code Size 321 Byte
Status AC
Exec Time 822 ms
Memory 369724 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 2
AC × 55
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 45 ms 17096 KiB
example_01.txt AC 45 ms 16996 KiB
hand_00.txt AC 822 ms 369724 KiB
hand_01.txt AC 543 ms 75160 KiB
hand_02.txt AC 658 ms 222280 KiB
hand_03.txt AC 809 ms 369380 KiB
hand_04.txt AC 557 ms 75044 KiB
hand_05.txt AC 673 ms 222228 KiB
hand_06.txt AC 726 ms 218900 KiB
hand_07.txt AC 591 ms 68184 KiB
hand_08.txt AC 590 ms 71828 KiB
hand_09.txt AC 579 ms 75420 KiB
hand_10.txt AC 594 ms 68476 KiB
hand_11.txt AC 544 ms 74960 KiB
hand_12.txt AC 531 ms 74908 KiB
hand_13.txt AC 549 ms 75032 KiB
hand_14.txt AC 398 ms 49884 KiB
hand_15.txt AC 664 ms 155840 KiB
hand_16.txt AC 676 ms 127156 KiB
hand_17.txt AC 626 ms 85896 KiB
hand_18.txt AC 665 ms 153844 KiB
hand_19.txt AC 649 ms 127780 KiB
hand_20.txt AC 623 ms 89476 KiB
hand_21.txt AC 546 ms 104620 KiB
hand_22.txt AC 793 ms 340080 KiB
random_00.txt AC 626 ms 68648 KiB
random_01.txt AC 602 ms 68624 KiB
random_02.txt AC 593 ms 67824 KiB
random_03.txt AC 595 ms 68536 KiB
random_04.txt AC 594 ms 68696 KiB
random_05.txt AC 597 ms 68712 KiB
random_06.txt AC 593 ms 68604 KiB
random_07.txt AC 596 ms 68736 KiB
random_08.txt AC 599 ms 68536 KiB
random_09.txt AC 597 ms 68744 KiB
random_10.txt AC 594 ms 68600 KiB
random_11.txt AC 594 ms 67692 KiB
random_12.txt AC 596 ms 68588 KiB
random_13.txt AC 594 ms 68612 KiB
random_14.txt AC 597 ms 68648 KiB
random_15.txt AC 599 ms 70932 KiB
random_16.txt AC 608 ms 70860 KiB
random_17.txt AC 598 ms 70976 KiB
random_18.txt AC 600 ms 71012 KiB
random_19.txt AC 603 ms 71064 KiB
random_20.txt AC 599 ms 71144 KiB
random_21.txt AC 596 ms 70952 KiB
random_22.txt AC 578 ms 75836 KiB
random_23.txt AC 583 ms 75980 KiB
random_24.txt AC 581 ms 75108 KiB
random_25.txt AC 586 ms 75964 KiB
random_26.txt AC 584 ms 76012 KiB
random_27.txt AC 587 ms 75720 KiB
random_28.txt AC 581 ms 75824 KiB
random_29.txt AC 580 ms 75800 KiB