No.2495 Three Sets
タグ : / 解いたユーザー数 29
作問者 :
Problem Statement
You are given positive integers $N_A,N_B,N_C$ and integer sequences $(A_1,A_2,\dots,A_{N_A}),(B_1,B_2,\dots,B_{N_B}),(C_1,C_2,\dots,C_{N_C})$.
For a triple $(S_A,S_B,S_C)$ consisting of a subset $S_A$ of $\{1,2,\dots,N_A\}$, a subset $S_B$ of $\{1,2,\dots,N_B\}$, and a subset $S_C$ of $\{1,2,\dots,N_C\}$, its score is defined as follows. \[\left(\sum_{i\in S_A}A_i\right)|S_B|+\left(\sum_{j\in S_B}B_j\right)|S_C|+\left(\sum_{k\in S_C}C_k\right)|S_A|\]
Here, $|S|$ denotes the number of elements of a set $S$. Also, $\sum_{x\in S}f(x)$ denotes the sum of $f(x)$ over all elements $x$ of a set $S$; in particular, if $S$ is empty, then $\sum_{x\in S}f(x)=0$.
Find the maximum possible value of the score.
Note that the answer may not fit in a 32-bit integer type.
Input
$N_A\ N_B\ N_C$
$A_1\ A_2\ \dots\ A_{N_A}$
$B_1\ B_2\ \dots\ B_{N_B}$
$C_1\ C_2\ \dots\ C_{N_C}$
- $1\leq N_A,N_B,N_C\leq 10^5$
- $|A_i|,|B_j|,|C_k|\leq 3\times 10^3$
- All input values are integers.
Output
Output the maximum possible value of the score. Print a newline at the end.
Sample
Sample 1
Input
2 3 3 -5 -2 2 -4 2 -3 -1 3
Output
12
For example, when $S_A=\{\},S_B=\{1,3\},S_C=\{1,2,3\}$, the score is $12$. It can be shown that the score cannot be made larger than this, so the value to output is $12$.
Sample 2
Input
4 4 4 -33 -333 -3 -33 -22 222 22 222 11 -11 111 11
Output
2023
Sample 3
Input
10 10 10 1211 -789 -318 1533 -2837 -1408 117 -30 2777 786 1770 -73 -846 282 2173 2234 2241 -303 -1617 168 498 1150 1730 -230 -1050 730 693 -700 794 349
Output
161276
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。