Universal Cup Judging System

Universal Cup

時間限制: 3.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓
统计

ご存知かもしれませんが、新しい問題を思いつく最良の方法は問題文を誤読することです。ここに、まさにそのような方法で生まれた問題があります。

$m$ 個の石と、それらを $n$ 個の箱に配分する $k$ 通りの配分方法があります。各配分は、$a_1 + \dots + a_n = m$ を満たす非負整数配列 $a$ として表されます。Alice は石の配分 $b$ を $1$ つ構成し、$a$ を $b$ に一致させるために必要な以下の操作の最小回数を $\operatorname{cost}(b, a)$ と定義します:

  • 石が $1$ 個以上入っている箱 $i$ ($1 \le i \le n$) から石を $1$ 個取り出し、箱 $j$ ($1 \le j \le n$) に入れる。

彼女は、最適な配分 $b$ に対する、与えられたすべての配分へのコストの総和の最小値を求めたいと考えています。

入力

最初の行には、箱の個数、石の個数、配分の個数を表す $3$ つの整数 $n, m, k$ ($1 \le n, k \le 400, 1 \le m \le 10^9$) が与えられます。

続く $k$ 行のそれぞれには、配分の内容を表す $n$ 個の非負整数 $a_{i,j}$ ($a_{i,1} + \dots + a_{i,n} = m$) が与えられます。

出力

問題の答えを表す整数を $1$ つ出力してください。

入出力例

入力例 1

5 12 3
3 0 4 1 4
5 2 3 1 1
1 2 3 5 1

出力例 1

8

入力例 2

1 1 2
1
1

出力例 2

0

注記

$1$ 番目のサンプルでは、最適な配分の $1$ つとして $b = \{3, 2, 3, 2, 2\}$ が挙げられます。この配分 $b$ に対して、以下のようになります:

  • $a = \{3, 0, 4, 1, 4\}$ に対しては、次の順序で操作を行えるため $\operatorname{cost}(b, a) = 3$ です:$\{3, 0, 4, 1, 4\} \to \{3, 1, 4, 1, 3\} \to \{3, 2, 4, 1, 2\} \to \{3, 2, 3, 2, 2\}$。
  • $a = \{5, 2, 3, 1, 1\}$ に対しては、次の順序で操作を行えるため $\operatorname{cost}(b, a) = 2$ です:$\{5, 2, 3, 1, 1\} \to \{4, 2, 3, 1, 2\} \to \{3, 2, 3, 2, 2\}$。
  • $a = \{1, 2, 3, 5, 1\}$ に対しては、次の順序で操作を行えるため $\operatorname{cost}(b, a) = 3$ です:$\{1, 2, 3, 5, 1\} \to \{1, 2, 3, 4, 2\} \to \{2, 2, 3, 3, 2\} \to \{3, 2, 3, 2, 2\}$。

したがってコストの総和は $8$ となります。これより小さいコストの総和を達成することは不可能であることが示せます。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#371EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.