
ZOJ Problem Set  3375
It's the eve of the Harvest Moon Festival in Gensokyo when Flandre Scarlet senses that something is wrong with the moon. It appears that the moon has been replaced by a fake moon. Someone must freeze time and find the real moon to ensure a full moon on the night of the festival. Remilia Scarlet tells her that she must go into the Bamboo Forest of the Lost (迷いの竹林) to investigate and gain enough points to remedy this. Flandre sets off immediately. When she arrives at the entry of the Bamboo Forest of the Lost, she finds that there are n different parts. According to Remilia, there are two kinds of mysterious halidom, ITEM and TIME, that will increase Flandre's points:
Obviously, Flandre's IV and TV will be changing when she is collecting ITEM and TIME, thus the order of collection is important. Morever, the order of the parts she chooses is crucial too. Flandre should gain as many points as possible. Your task is to calculate the maximal point Flandre can gain. InputThe input contains multiple test cases (no more than 100). The first line of each case is an integer n (1 ≤ n ≤ 15), indicating the number of parts of the forest. Then follows n lines, the ith (1 ≤ i ≤ n) of them contains 4 integers a_{i}, b_{i}, x_{i}, y_{i} (0 ≤ a_{i}, b_{i} ≤ 20, 0 ≤ x_{i}, y_{i} ≤ 30), as described above. OutputFor each case, output the maximal point Flandre can gain in a single line. Sample Input1 1 2 1 1 3 2 2 2 2 2 2 2 2 2 2 2 2 Sample Output2 72 ReferencesAuthor: LI, Dinghua Source: ACM × Touhou Contest: ZOJ Monthly, August 2010 