結果

問題 No.2261 Coffee
ユーザー ks2mks2m
提出日時 2023-04-08 00:04:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 773 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 77,572 KB
実行使用メモリ 56,968 KB
最終ジャッジ日時 2024-04-10 18:22:04
合計ジャッジ時間 20,086 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
37,316 KB
testcase_01 AC 45 ms
37,140 KB
testcase_02 AC 45 ms
37,112 KB
testcase_03 AC 47 ms
37,328 KB
testcase_04 AC 49 ms
37,184 KB
testcase_05 AC 50 ms
37,500 KB
testcase_06 AC 46 ms
37,232 KB
testcase_07 AC 47 ms
36,980 KB
testcase_08 AC 45 ms
37,352 KB
testcase_09 AC 45 ms
37,572 KB
testcase_10 AC 50 ms
37,532 KB
testcase_11 AC 54 ms
37,504 KB
testcase_12 AC 50 ms
37,300 KB
testcase_13 AC 49 ms
36,984 KB
testcase_14 AC 55 ms
37,464 KB
testcase_15 AC 50 ms
37,232 KB
testcase_16 AC 48 ms
37,516 KB
testcase_17 AC 157 ms
41,808 KB
testcase_18 AC 162 ms
41,840 KB
testcase_19 AC 153 ms
41,708 KB
testcase_20 AC 145 ms
41,860 KB
testcase_21 AC 155 ms
41,832 KB
testcase_22 AC 151 ms
41,760 KB
testcase_23 AC 165 ms
42,740 KB
testcase_24 AC 635 ms
52,348 KB
testcase_25 AC 647 ms
51,592 KB
testcase_26 AC 666 ms
52,808 KB
testcase_27 AC 644 ms
52,156 KB
testcase_28 AC 568 ms
55,944 KB
testcase_29 AC 529 ms
55,644 KB
testcase_30 AC 497 ms
53,032 KB
testcase_31 AC 757 ms
56,032 KB
testcase_32 AC 620 ms
55,684 KB
testcase_33 AC 596 ms
56,968 KB
testcase_34 AC 586 ms
56,832 KB
testcase_35 AC 691 ms
56,828 KB
testcase_36 AC 773 ms
56,544 KB
testcase_37 AC 604 ms
56,460 KB
testcase_38 AC 614 ms
52,504 KB
testcase_39 AC 658 ms
52,872 KB
testcase_40 AC 632 ms
52,732 KB
testcase_41 AC 638 ms
53,328 KB
testcase_42 AC 632 ms
52,600 KB
testcase_43 AC 618 ms
52,688 KB
testcase_44 AC 620 ms
52,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		long[][] a = new long[n][5];
		for (int i = 0; i < n; i++) {
			String[] sa = br.readLine().split(" ");
			for (int j = 0; j < 5; j++) {
				a[i][j] = Long.parseLong(sa[j]);
			}
		}
		br.close();

		long[] min = new long[32];
		long[] max = new long[32];
		Arrays.fill(min, Long.MAX_VALUE);
		Arrays.fill(max, Long.MIN_VALUE);
		for (int i = 0; i < n; i++) {
			for (int k = 0; k < 32; k++) {
				long v = 0;
				for (int j = 0; j < 5; j++) {
					if ((k >> j & 1) == 1) {
						v += a[i][j];
					} else {
						v -= a[i][j];
					}
				}
				min[k] = Math.min(min[k], v);
				max[k] = Math.max(max[k], v);
			}
		}

		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 0; i < n; i++) {
			long ans = 0;
			for (int k = 0; k < 32; k++) {
				long v = 0;
				for (int j = 0; j < 5; j++) {
					if ((k >> j & 1) == 1) {
						v += a[i][j];
					} else {
						v -= a[i][j];
					}
				}
				ans = Math.max(ans, v - min[k]);
				ans = Math.max(ans, max[k] - v);
			}
			pw.println(ans);
		}
		pw.flush();
	}
}
0