P2392 kkksc03's Last-Minute Cramming Before the Exam

Background

kkksc03's college life is very unmotivated; he usually does not study. However, with the final exams approaching, he must start cramming to avoid failing.

Description

For this final exam, kkksc03 needs to take $4$ subjects. Therefore, he begins practicing problem sets. Each subject has a problem set with $s_1,s_2,s_3,s_4$ problems, and each problem takes some (possibly different) amount of time to complete ($A_1,A_2,\ldots,A_{s_1}$, $B_1,B_2,\ldots,B_{s_2}$, $C_1,C_2,\ldots,C_{s_3}$, $D_1,D_2,\ldots,D_{s_4}$). kkksc03 has an ability: his left and right brains can work on $2$ different problems simultaneously, but only within the same subject. Therefore, kkksc03 must review one subject at a time. Since kkksc03 is also in a hurry to handle Luogu's bugs, he wants to finish as quickly as possible. He wants to know the minimum time required to complete all the review.

Input Format

This problem contains $5$ lines of input. - The first line contains four positive integers $s_1,s_2,s_3,s_4$. - The second line contains $A_1,A_2,\ldots,A_{s_1}$, a total of $s_1$ numbers, representing the time required for each problem in the first subject's problem set. - The third line contains $B_1,B_2,\ldots,B_{s_2}$, a total of $s_2$ numbers. - The fourth line contains $C_1,C_2,\ldots,C_{s_3}$, a total of $s_3$ numbers. - The fifth line contains $D_1,D_2,\ldots,D_{s_4}$, a total of $s_4$ numbers, with the same meaning as above.

Output Format

Output one line: the minimum time to finish all the review.

Explanation/Hint

$1\leq s_1,s_2,s_3,s_4\leq 20$. $1\leq A_1,A_2,\ldots,A_{s_1},B_1,B_2,\ldots,B_{s_2},C_1,C_2,\ldots,C_{s_3},D_1,D_2,\ldots,D_{s_4}\leq 60$. Translated by ChatGPT 5