問題一覧 > 通常問題

No.2261 Coffee

レベル : / AI推定難易度 : 1550 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 150
作問者 : karinohito / テスター : とりゐ sotanishy
お気に入りにしたユーザー ProblemId : 9366 / 自分の提出
問題文最終更新日: 2023-04-07 21:18:21
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 383 (順位表) の他の問題:

Problem Statement

Aoba Coffee Shop sells $N$ types of coffee beans.
Each type of coffee bean has fixed flavor parameters: bitterness, astringency, acidity, aroma, and richness. The parameter values of the $i\ (1\le i\le N)$-th bean are $A_i,B_i,C_i,D_i,E_i$, respectively.
The difference in flavor $d(i,j)$ between the $i$-th bean and the $j$-th bean is expressed as
$$d(i,j):=|A_i-A_j|+|B_i-B_j|+|C_i-C_j|+|D_i-D_j|+|E_i-E_j|$$
.
Hirose, who visited this shop, decided to buy 2 types of beans.
Since Hirose wants to enjoy a variety of coffees, Hirose decided to buy 2 types of beans so that the difference in flavor is large.
For each $k=1,2,\dots,N$, find the value of $\displaystyle\max_{1\le j\le N}d(k,j)$.

Input

$N$  
$A_1$ $B_1$ $C_1$ $D_1$ $E_1$  
$A_2$ $B_2$ $C_2$ $D_2$ $E_2$  
$\vdots$  
$A_N$ $B_N$ $C_N$ $D_N$ $E_N$

  • $2 \leq N \leq 10^5$
  • $1 \leq A_i,B_i,C_i,D_i,E_i \leq 10^{15}$
  • All inputs are integers.

Output

Print $N$ lines.
On the $k$-th line $(k=1,2,\dots,N)$, print the value of $\displaystyle\max_{1\le j\le N}d(k,j)$.

Sample

Sample 1
Input
3
1 4 1 4 2
2 4 4 9 4
2 6 4 5 7
Output
12
11
12

The difference in flavor between the 1st and 2nd beans is $|1-2|+|4-4|+|1-4|+|4-9|+|2-4|=11$.
The difference in flavor between the 1st and 3rd beans is $|1-2|+|4-6|+|1-4|+|4-5|+|2-7|=12$.
The difference in flavor between the 2nd and 3rd beans is $|2-2|+|4-6|+|4-4|+|9-5|+|4-7|=9$.

Sample 2
Input
5
94141 61516 1160 84124 461413
1146 8242367237 6623526 79272 153
96246 7512214 17138569 151611 1783836210
512415 192720 245373478 18932163 431516435
91241 1 10243532362 8176947 1275254151
Output
11526481178
19762717840
10750518406
10853265709
19762717840

Sample 3
Input
3  
3 1 4 1 5  
3 1 4 1 5  
3 1 4 1 5  
Output
0
0
0

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