問題一覧 > 通常問題

No.1359 [Zelkova 3rd Tune] Four-Person Saison

レベル : / AI推定難易度 : 1150 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 153
作問者 : 👑 Kazun / テスター : nok0
お気に入りにしたユーザー ProblemId : 5152 / 自分の提出
問題文最終更新日: 2021-01-22 20:09:55
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 279 (Zelkova and Cherry) (順位表) の他の問題:

Notice

The problems of yukicoder contest 279 (Zelkova and Cherry) are not sorted in order of difficulty. Therefore, it is strongly recommended that you choose which problems to work on based on publicly available information such as the problem statements, the number of stars indicating difficulty, and the number of solvers.

Problem Statement

A tournament was held with $N$ people each from the Spring Country, the Summer Country, the Autumn Country, and the Winter Country, for a total of $4N$ people. As the groups that will compete in the preliminary round of this tournament, we form $N$ groups $G_1,\dots,G_N$, each consisting of one person from each of the Spring, Summer, Autumn, and Winter Countries. In addition, each participant of this tournament has a rating, and using these values, the following are defined.

  • Let $X_k,Y_k$ be the maximum and the minimum, respectively, of the ratings of the four people in group $G_k$. The unfairness $D_k$ of group $G_k$ is defined as $D_k:=X_k-Y_k$.
  • The unfairness of the preliminary round is defined as $\displaystyle \sum_{k=1}^N D_k^K$.

Find the minimum value $F$ of the unfairness of the preliminary round. Since $F$ can be very large, output $F$ modulo $M$. Note that you are not asked to find the minimum value of the unfairness of the preliminary round modulo $M$.
Here, the ratings of the $i$-th participants of the Spring, Summer, Autumn, and Winter Countries are $P_i,E_i,A_i,H_i$, respectively.

Constraints

  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq K \leq 10^9$
  • $1 \leq M \leq 10^9$
  • $0 \leq P_i,E_i,A_i,H_i \leq 10^9~(i=1,2,\dots,N)$
  • All inputs are integers.

Input

$N\ K\ M$
$P_1\ P_2\ \dots \ P_N$
$E_1\ E_2\ \dots \ E_N$
$A_1\ A_2\ \dots \ A_N$
$H_1\ H_2\ \dots \ H_N$

Output

Output the minimum value of the unfairness of the preliminary round achievable over all possible groupings, modulo $M$. Do not forget the newline.

Sample

Sample 1
Input
2 2 100
1 1000
1002 2
3 1004
1006 4
Output
45

If the two groups are formed so that their ratings are $(1,2,3,4), (1000,1002,1004,1006)$, the unfairness values of the two groups are $3,6$ respectively, so the unfairness of the preliminary round is $3^2+6^2=45$. Moreover, no matter how the groups are formed, the unfairness of the preliminary round cannot be made less than $45$.

Sample 2
Input
1 4 10000
5
10
15
20
Output
625

The only possible grouping is $(5,10,15,20)$, and the unfairness of the preliminary round is $15^4=50625$, so the answer is $625$, the remainder when this is divided by $10000$.

Sample 3
Input
9 20210122 123456789
14 14 21 35 62 37 30 95 4
88 1 68 87 24 20 96 98 7
85 69 67 18 75 37 69 48 7
31 76 67 97 37 99 7 32 47
Output
39598529

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。