Skip to content

Commit 1736198

Browse files
Update Parsa and Humungous Tree Explanation.txt
1 parent 6d10068 commit 1736198

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

2021/Div 2/722/Explanations/Parsa and Humungous Tree Explanation.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
In the optimal value, every vertex will either be set to the left or right extreme.
22

3-
Let us suppose that this is not the case.
3+
Let us consider some assignment of values to the tree and let v be some vertex which is not set to it's optimal value.
4+
We will show that assigning v = L[v] or v = R[v] will not result in a smaller answer
5+
And the answer will either increase or stay the same.
6+
7+
- Let there be X neighbours with value smaller than v and Y neighbours with a larger value.
8+
- If X > Y, we can set v = R_v and get a larger answer.
9+
- Increasing v by 1, increases the sum by X - Y
10+
- Similarly, if X < Y, we can set v = L_v for a larger answer.
11+
- If X = Y, we can set it to either L_v, R_v and the answer will not change.
412

513
-----
614

0 commit comments

Comments
 (0)